Prometheus
/api/metrics returns every queue on every connection in one scrape, in Prometheus’s text format.
It uses the metric names of BullMQ’s own exportPrometheusMetrics(), which covers one queue at a
time, and adds a connection label, so dashboards built on BullMQ’s export keep working.
Set up the scrape
Section titled “Set up the scrape”Make a long random token, give it to Bullship as BULLSHIP_METRICS_TOKEN and to Prometheus as a
credentials file:
openssl rand -hex 24 > bullship-tokenBULLSHIP_METRICS_TOKEN=$(cat bullship-token)scrape_configs: - job_name: bullship metrics_path: /api/metrics authorization: { credentials_file: /etc/prometheus/bullship-token } static_configs: [{ targets: ['bullship:3200'] }]A signed-in session or any API token (a viewer is enough) can read it too;
anything else gets 401. With sign-in off (BULLSHIP_AUTH=false or viewer), the endpoint is
open, like every other route, until you set a token.
curl -H "Authorization: Bearer $BULLSHIP_METRICS_TOKEN" http://localhost:3200/api/metricsbullmq_job_count{connection="default",queue="email.send",state="waiting"} 12bullmq_job_count{connection="default",queue="email.send",state="failed"} 53bullship_connection_up{connection="default"} 1…Metrics
Section titled “Metrics”| Metric | |
|---|---|
bullmq_job_count{connection,queue,state} |
Jobs per state: waiting, active, delayed, prioritized, waiting-children, paused, completed, failed |
bullmq_job_completed_total, bullmq_job_failed_total |
BullMQ’s running totals; only for queues whose workers have metrics on |
bullship_queue_oldest_waiting_seconds |
Age of the oldest job in the wait list, 0 when it is empty |
bullship_queue_workers |
Connected workers; absent when Redis refuses CLIENT LIST |
bullship_queue_paused |
1 when the queue is paused |
bullship_connection_up |
1 when the connection answered. A Redis that is down or takes over 5 s reads 0, and the rest of the scrape still answers |
bullship_connection_queues |
Queues on the connection |
bullship_connection_scrape_seconds |
How long reading the connection took |
What a scrape costs
Section titled “What a scrape costs”A scrape reads what the queue list reads, plus three O(1) reads per queue. Results are shared for 5 seconds, so several scrapers, or Prometheus replicas, cost the same as one. Queue names are rediscovered once a minute, so a new queue appears within 60 seconds.
Measured with Prometheus 3.16 scraping every 5 s, against Redis 8.0 holding 341 queues (about 963,000 keys and 2.2 GB):
| Measure | |
|---|---|
| Response | 3,787 samples, 282 KB |
Scrape time (scrape_duration_seconds) |
15 ms |
| Redis time per scrape | 19 ms over 5,449 O(1) commands |
| 50 concurrent scrapes | the same as one |
| Once a minute, rediscovering queues | +0.67 s of Redis time, 0.9 s scrape |
| Slowest Redis command while scraping | under 5 ms |
| Bullship heap / RSS after 50 concurrent scrapes | 27 / 155 MB |