Skip to content

Monitor queues

Three indicators report on queues. They are off by default:

Add them to health.indicators, with the thresholds that fit your traffic:

config/actuator.php
use Nwidart\Actuator\Health\Indicators\FailedJobsHealthIndicator;
use Nwidart\Actuator\Health\Indicators\HorizonHealthIndicator;
use Nwidart\Actuator\Health\Indicators\QueueHealthIndicator;
'indicators' => [
// ...
'queue' => [QueueHealthIndicator::class, ['warningThreshold' => 100, 'downThreshold' => 1000]],
'failedJobs' => [FailedJobsHealthIndicator::class, ['downThreshold' => 50, 'minutes' => 60]],
'horizon' => HorizonHealthIndicator::class,
],

Leave out horizon if you do not run Horizon: without laravel/horizon, it reports UNKNOWN.

The queue indicator watches the default queue of the default connection. List other queues in queue.queues, by connection:

config/actuator.php
'queue' => [
'queues' => [
'redis' => ['default', 'emails'],
'sqs' => ['reports'],
],
],

Each queue gets its own counts in the details:

"queue": {
"status": "UP",
"details": {
"queues": {
"redis": {
"default": { "size": 12, "pending": 10, "delayed": 1, "reserved": 1 },
"emails": { "size": 0, "pending": 0, "delayed": 0, "reserved": 0 }
},
"sqs": { "reports": { "size": 3, "pending": 3, "delayed": 0, "reserved": 0 } }
},
"warningThreshold": 100,
"downThreshold": 1000
}
}

pending, delayed and reserved need Laravel 12.20 or later. Before, and with a driver that cannot count them, the details show only size.

A queue that cannot be read shows an error and makes the indicator DOWN. When the first queue of a connection fails, the indicator skips the other queues of that connection: a connection that does not answer costs one connect timeout per probe, not one per queue. Keep the connect timeouts of your queue connections below the probe’s timeout. A queue that may be missing, such as an SQS queue you may delete, goes after the others or on a connection of its own. See QueueHealthIndicator.

A queue at or over warningThreshold makes the indicator WARNING. A queue at or over downThreshold makes it DOWN. null turns a threshold off. The largest queue decides.

failedJobs is WARNING from one failed job. Set minutes to count only the recent failures: without it, an old failure keeps the indicator WARNING until you retry or delete the job. Only the database and database-uuids failers count within a window.

Add a queues group, and point your alerting or dashboard at /actuator/health/queues:

config/actuator.php
'groups' => [
'liveness' => ['include' => ['ping']],
'readiness' => ['include' => ['readinessState', 'migrations']],
'queues' => ['include' => ['queue', 'failedJobs', 'horizon']],
],

The indicators still count in /actuator/health, which aggregates every indicator. WARNING answers 200; DOWN answers 503.

Each probe runs every indicator of the group. On the database queue driver, the queue indicator runs a COUNT(*) on the jobs table for each queue, and failedJobs counts the failed jobs table. Reuse the results for a few seconds:

.env
ACTUATOR_HEALTH_CACHE_TTL=5

See health.cache.

To graph the backlog and alert on it in Prometheus, export the watched queues as gauges of the prometheus endpoint:

.env
ACTUATOR_QUEUE_METRICS=true

laravel_queue_size has the size of each queue of queue.queues, and laravel_queue_jobs its pending, delayed and reserved jobs. laravel_queue_failed_jobs counts the failed jobs. See queue metrics.

Each scrape counts every queue again: the health cache does not apply. On the database driver, that is a COUNT(*) on the jobs table for each queue and state. A queue that cannot be read loses its own series. A connection that fails on its first queue is skipped for its other queues, so it costs one connect timeout per scrape. Any error on the first queue counts as a connection error, even one of that queue alone, such as a deleted SQS queue. A slow connection still holds the whole scrape, and past scrape_timeout every metric of the instance is missing. Keep the connect timeouts of your queue connections short.

A Prometheus alert when a queue stays above 1,000 jobs for 10 minutes:

alerts.yml
groups:
- name: laravel
rules:
- alert: QueueBacklog
expr: max by (connection, queue) (laravel_queue_size) > 1000
for: 10m
annotations:
summary: "{{ $labels.queue }} on {{ $labels.connection }} holds {{ $value }} jobs"
Terminal window
php artisan actuator:health queues --details