Skip to content

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"}

Metrics at a glance

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.

state label for asynq_tasks_enqueued_total

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.

What is included in asynq_queue_size

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.

Common PromQL queries

Failed task attempts in the last five minutes

increase(asynq_tasks_failed_total[5m])

Failure rate in the last five minutes

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.

Current executable backlog

asynq_tasks_enqueued_total{state="pending"}

Paused queues

asynq_queue_paused_total == 1

Oldest pending task has waited more than five minutes

asynq_queue_latency_seconds > 300

Notes on use

  • Use rate() or increase() with asynq_tasks_failed_total and asynq_tasks_processed_total to observe changes over time; their instantaneous absolute values do not represent current load.
  • Although their names end with _total, asynq_tasks_enqueued_total and asynq_queue_paused_total are implemented as Gauges. Read their current values directly; do not use rate() or increase() with them.
  • asynq_queue_latency_seconds is based only on the oldest pending task. Tasks waiting for a future scheduled or retry time 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.

Implementation references

Clone this wiki locally

⌂ 换网址