|
| 1 | +# Pgbus automated dashboard |
| 2 | + |
| 3 | +[Pgbus](https://github.com/mhenrixon/pgbus) is a PostgreSQL-native job processing and event bus for Rails, built on [PGMQ](https://github.com/pgmq/pgmq). |
| 4 | + |
| 5 | +When using the AppSignal integration that ships with the pgbus gem (enabled automatically when the `appsignal` gem is loaded), the Pgbus automated dashboard will appear. Pgbus reports metrics through an `ActiveSupport::Notifications` subscriber and a minutely probe. See the [pgbus AppSignal integration](https://github.com/mhenrixon/pgbus/blob/main/lib/pgbus/integrations/appsignal.rb) for the full list of metrics. |
| 6 | + |
| 7 | +The following graphs are displayed in this automated dashboard: |
| 8 | + |
| 9 | +- [Job status per queue](#job-status-per-queue) |
| 10 | +- [Throughput per job class](#throughput-per-job-class) |
| 11 | +- [Duration per job class](#duration-per-job-class) |
| 12 | +- [Queue depth](#queue-depth) |
| 13 | +- [Queue latency](#queue-latency) |
| 14 | +- [Dead letter queue depth](#dead-letter-queue-depth) |
| 15 | +- [Worker / Process count](#worker--process-count) |
| 16 | +- [Messages sent / read](#messages-sent--read) |
| 17 | +- [Event handler status](#event-handler-status) |
| 18 | +- [Worker recycling](#worker-recycling) |
| 19 | +- [Database health](#database-health) |
| 20 | +- [Stream broadcasts](#stream-broadcasts) |
| 21 | + |
| 22 | +## Job status per queue |
| 23 | + |
| 24 | +The "Job status per queue" graph shows the number of jobs that were processed, failed, or dead-lettered, broken down per queue. |
| 25 | + |
| 26 | +This graph displays values from the `pgbus_queue_job_count` metric. This graph will show a line for each combination of values of the following metric tags: |
| 27 | + |
| 28 | +- The **queue** in which each job was enqueued. |
| 29 | +- The **status** of the job (`processed`, `failed`, or `dead_lettered`). |
| 30 | + |
| 31 | +## Throughput per job class |
| 32 | + |
| 33 | +The "Throughput per job class" graph shows the number of jobs executed per job class. |
| 34 | + |
| 35 | +This graph displays the `count` field of the `transaction_duration` metric, filtered to the `background` namespace, with a line per **action** (job class). |
| 36 | + |
| 37 | +## Duration per job class |
| 38 | + |
| 39 | +The "Duration per job class" graph shows the mean execution time per job class. |
| 40 | + |
| 41 | +This graph displays the `mean` field of the `transaction_duration` metric, filtered to the `background` namespace, with a line per **action** (job class). |
| 42 | + |
| 43 | +## Queue depth |
| 44 | + |
| 45 | +The "Queue depth" graph shows the total number of messages waiting in each queue. |
| 46 | + |
| 47 | +This graph displays values from the `pgbus_queue_depth` metric. This graph will show a line for each combination of values of the following metric tags: |
| 48 | + |
| 49 | +- The **queue** being measured. |
| 50 | +- The **hostname** of the process that reported the metric. |
| 51 | + |
| 52 | +## Queue latency |
| 53 | + |
| 54 | +The "Queue latency" graph shows the age of the oldest message in each queue, in milliseconds. High latency means consumers can't keep up with the rate of incoming messages. |
| 55 | + |
| 56 | +This graph displays values from the `pgbus_queue_latency` metric. This graph will show a line for each combination of values of the following metric tags: |
| 57 | + |
| 58 | +- The **queue** being measured. |
| 59 | +- The **hostname** of the process that reported the metric. |
| 60 | + |
| 61 | +## Dead letter queue depth |
| 62 | + |
| 63 | +The "Dead letter queue depth" graph shows the number of messages that exceeded their max retries and were routed to a dead letter queue. |
| 64 | + |
| 65 | +This graph displays values from the `pgbus_dlq_depth` metric, with a line per **hostname**. |
| 66 | + |
| 67 | +## Worker / Process count |
| 68 | + |
| 69 | +The "Worker / Process count" graph shows the number of active pgbus supervisor processes. |
| 70 | + |
| 71 | +This graph displays values from the `pgbus_active_processes` metric, with a line per **hostname**. |
| 72 | + |
| 73 | +## Messages sent / read |
| 74 | + |
| 75 | +The "Messages sent / read" graph shows PGMQ message throughput: how many messages were enqueued (`pgbus_messages_sent`) and dequeued (`pgbus_messages_read`). |
| 76 | + |
| 77 | +Both metrics show a line per **queue**. |
| 78 | + |
| 79 | +## Event handler status |
| 80 | + |
| 81 | +The "Event handler status" graph shows the number of processed and failed event-bus handler invocations. |
| 82 | + |
| 83 | +This graph displays values from the `pgbus_event_count` metric. This graph will show a line for each combination of values of the following metric tags: |
| 84 | + |
| 85 | +- The **handler** class that processed each event. |
| 86 | +- The **status** of the invocation (`processed` or `failed`). |
| 87 | + |
| 88 | +## Worker recycling |
| 89 | + |
| 90 | +The "Worker recycling" graph shows the number of worker recycle events, broken down by reason. |
| 91 | + |
| 92 | +This graph displays values from the `pgbus_worker_recycled` metric, with a line per **reason** (`max_jobs`, `max_memory`, or `max_lifetime`). Pgbus recycles workers on these thresholds to prevent unbounded memory growth. |
| 93 | + |
| 94 | +## Database health |
| 95 | + |
| 96 | +The "Database health" graph shows the number of dead tuples in queue/archive tables (`pgbus_total_dead_tuples`) and how many tables currently need a vacuum (`pgbus_tables_needing_vacuum`). |
| 97 | + |
| 98 | +Both metrics show a line per **hostname**. These are indicators of MVCC pressure on the PGMQ queue tables. |
| 99 | + |
| 100 | +## Stream broadcasts |
| 101 | + |
| 102 | +The "Stream broadcasts" graph shows the number of Turbo Stream broadcasts over the last 60 minutes (`pgbus_stream_broadcasts_60m`) and the number of active SSE connections (`pgbus_stream_active_connections`). |
| 103 | + |
| 104 | +Both metrics show a line per **hostname**. |
0 commit comments