---
title: "Alert on the age of the oldest waiting job · Agent Wranglers"
url: https://agentwranglers.se/playbook/operations/alerts-and-on-call/queue-age
updated: 2026-10-21
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Alert on the age of the oldest waiting job

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Alerts and on-call](https://agentwranglers.se/playbook/operations/alerts-and-on-call.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

- ID: OPS-67
- Level: Recommended
- Chapter: [Alerts and on-call](https://agentwranglers.se/playbook/operations/alerts-and-on-call)
- Rule: For every queue and data pipeline, measure the age of the oldest item still waiting. Alert when it passes the delay users accept, such as 15 minutes.
- How: A queue that grows slowly sends no errors, so emails, exports or reports arrive hours late before anyone notices. The length of a queue varies with traffic, but the age of its oldest item shows the delay users feel. Write the accepted delay as a freshness objective, as in [set a target for each indicator](https://agentwranglers.se/playbook/operations/service-levels/service-level-objectives). Export the age as a metric every minute, and alert as a ticket or a page by [page only for what cannot wait](https://agentwranglers.se/playbook/operations/alerts-and-on-call/page-or-ticket). Items that keep failing go to a [dead letter queue](https://agentwranglers.se/playbook/scaling/background-jobs-and-queues/dead-letter-queue), so they never hold the age up.
- Check: Stop the workers of one queue on staging and add one job. The alert fires within the accepted delay plus 5 minutes, and clears within 5 minutes after the workers restart.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
const oldest = await db.query(
  "SELECT EXTRACT(EPOCH FROM now() - min(created_at)) AS age FROM jobs WHERE status = 'waiting'"
);
queueAgeSeconds.set({ queue: 'emails' }, Number(oldest.rows[0].age ?? 0));
```

### Python example

```python
row = db.execute(
    "SELECT EXTRACT(EPOCH FROM now() - min(created_at)) FROM jobs WHERE status = 'waiting'"
).fetchone()
queue_age_seconds.labels(queue="emails").set(row[0] or 0)
```

## Sources

- [Google SRE workbook, Data Processing Pipelines](https://sre.google/workbook/data-processing/)

## Related rules

- [Set a target for each indicator](https://agentwranglers.se/playbook/operations/service-levels/service-level-objectives) in Operations
- [Page only for what cannot wait](https://agentwranglers.se/playbook/operations/alerts-and-on-call/page-or-ticket) in Operations
- [Set aside messages that keep failing](https://agentwranglers.se/playbook/scaling/background-jobs-and-queues/dead-letter-queue) in Scaling
- [Test the service against every platform limit](https://agentwranglers.se/playbook/infrastructure/hosting-platforms/platform-limits) in Infrastructure
- [Bound the backlog and push back on producers](https://agentwranglers.se/playbook/scaling/background-jobs-and-queues/bounded-backlog) in Scaling
- [Keep urgent jobs in their own queue](https://agentwranglers.se/playbook/scaling/background-jobs-and-queues/urgent-queue) in Scaling
- [Scale on the resource that runs out](https://agentwranglers.se/playbook/scaling/load-balancing-and-autoscaling/scale-on-saturation) in Scaling

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/operations/alerts-and-on-call/queue-age">Agent Wranglers operations playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Alert when a scheduled job stops running](https://agentwranglers.se/playbook/operations/alerts-and-on-call/job-heartbeats)
- Next: [Prove that alerts still reach you](https://agentwranglers.se/playbook/operations/alerts-and-on-call/alert-pipeline-heartbeat)
- [Alerts and on-call](https://agentwranglers.se/playbook/operations/alerts-and-on-call)
