Skip to main content
BullMQ provides built-in metrics functionality that allows you to track the performance of your queues over time. Workers can count the number of jobs they process per minute and store this data in Redis for later analysis.

Enabling Metrics

Enable metrics collection on your workers by specifying how many data points to keep:
metrics.maxDataPoints
number
required
Number of data points (minutes) to store. Each data point represents one minute of metrics.
All workers for the same queue must use the same metrics settings to get consistent data.

MetricsTime Constants

BullMQ provides convenient time constants:

Common Configurations

Memory Usage

Metrics are stored efficiently in Redis:
  • Data points are 1-minute intervals
  • 2 weeks of data ≈ 120 KB per queue
  • Older data is automatically removed
  • Memory usage remains constant after reaching max data points

Querying Metrics

Retrieve metrics using the getMetrics method on the Queue class:

Method Signature

type
'completed' | 'failed'
required
The type of metrics to retrieve: completed for successful jobs or failed for failed jobs.
start
number
default:"0"
Starting index for pagination. Use 0 to start from the beginning.
end
number
default:"-1"
Ending index for pagination. Use -1 to retrieve all data.

Metrics Response Format

The getMetrics method returns a Metrics object:

Example Response

Understanding the Data

data array:
  • Each element represents one minute
  • Value is the number of jobs completed (or failed) in that minute
  • Ordered from oldest to newest
count field:
  • Total number of jobs completed (or failed) since the queue started
  • Not limited to the queried time range
  • Useful for long-term tracking
meta fields:
  • Used internally by the metrics system
  • prevTS and prevCount should not be used in application code

Practical Examples

Example 1: Basic Metrics Tracking

Example 2: Performance Dashboard

Example 3: Alerting on Failures

Example 4: Paginated Metrics

Example 5: Calculating Throughput

Prometheus Integration

For Prometheus metrics export, see Prometheus documentation.

Best Practices

1

Use consistent settings across workers

All workers for the same queue must have identical metrics configuration.
2

Start with 2 weeks of data

This provides good balance between memory usage (~120 KB) and historical data.
3

Monitor both completed and failed metrics

Track success rate by comparing completed vs failed job counts.
4

Set up alerts for anomalies

Monitor failure rates, throughput drops, or unusual patterns.
5

Use pagination for large datasets

When querying long time ranges, use pagination to avoid loading too much data.
6

Combine with external monitoring

Integrate with Prometheus, Grafana, or other monitoring tools for visualization.

Limitations

Metrics are aggregated in 1-minute intervals. You cannot get sub-minute granularity.
The count field shows all-time totals, not just the queried time range.
Metrics data is stored in Redis and will be lost if Redis is flushed or data is not persisted.

Telemetry

OpenTelemetry integration for tracing

Queue Events

Listen to job events in real-time

Workers Overview

Configure and manage workers

Going to Production

Production deployment best practices

API Reference