Repository navigation
Asynq Queue Prometheus Metrics
yichuandeng edited this page Aug 18, 2026
·
1 revision
This document describes the queue-level Prometheus metrics exported by metrics.NewQueueMetricsCollector.
All metrics have a queue label to identify the queue. For example:
asynq_queue_latency_seconds{queue="critical"}
| Metric | Type | Labels | Description |
|---|---|---|---|
asynq_queue_paused_total |
Gauge | queue |
Whether a queue is paused: 1 means paused and 0 means not paused. Tasks in a paused queue are not processed. Despite its _total suffix, this is not an accumulated value. |
asynq_tasks_enqueued_total |
Gauge |
queue, state
|
Current number of tasks in a given queue and state. Despite its _total suffix, this is not a historical total of enqueues. |
asynq_tasks_failed_total |
Counter | queue |
Cumulative number of failed task-processing attempts in the queue. |
asynq_tasks_processed_total |
Counter | queue |
Cumulative number of task-processing attempts in the queue, including both successful and failed attempts. Each retry is counted as a separate processing attempt. |
asynq_queue_size |
Gauge | queue |
Current total number of tasks stored in the queue across several states. It is not limited to tasks waiting to be executed. |
asynq_queue_latency_seconds |
Gauge | queue |
Time, in seconds, that the oldest pending task has waited to be processed. It is 0 when there are no pending tasks. |
asynq_tasks_enqueued_total reports the current task count for each state. The following state values are exported:
state |
Description |
|---|---|
pending |
Tasks waiting for a worker to start processing them. This is generally the most direct indicator of executable backlog. |
active |
Tasks currently being processed by a worker. |
scheduled |
Tasks already enqueued but scheduled to be processed at a future time. |
retry |
Tasks whose latest attempt was unsuccessful and that are waiting for the next retry. |
archived |
Tasks that reached a terminal failure state and were archived. |
completed |
Successfully processed tasks that are still retained. |
This metric is the sum of tasks in these states:
pending + active + scheduled + retry + archived + completed + aggregating
To monitor tasks currently waiting for worker execution, prefer:
asynq_tasks_enqueued_total{state="pending"}
rather than asynq_queue_size.
increase(asynq_tasks_failed_total[5m])
sum(increase(asynq_tasks_failed_total[5m]))
/
sum(increase(asynq_tasks_processed_total[5m]))
When using this expression in an alert, handle a zero denominator so that periods with no task processing do not produce meaningless results.
asynq_tasks_enqueued_total{state="pending"}
asynq_queue_paused_total == 1
asynq_queue_latency_seconds > 300
- Use
rate()orincrease()withasynq_tasks_failed_totalandasynq_tasks_processed_totalto observe changes over time; their instantaneous absolute values do not represent current load. - Although their names end with
_total,asynq_tasks_enqueued_totalandasynq_queue_paused_totalare implemented as Gauges. Read their current values directly; do not userate()orincrease()with them. -
asynq_queue_latency_secondsis based only on the oldestpendingtask. Tasks waiting for a futurescheduledorretrytime do not increase this metric. - The values are snapshots of Redis queue state at collection time. Collection frequency affects the freshness of dashboards and alerts.
- Metric names, labels, and Prometheus types:
x/metrics/metrics.go - Queue states and the
Sizecalculation:inspector.goandinternal/rdb/inspect.go