You are setting up an alert on a work queue. Do you alert on depth or on age of the oldest message?
Sketch your own answer first, then compare it with the one below.
A strong answer
Age, with depth as a supporting graph.
A depth threshold is tied to consumer speed. An alert at 5,000 messages is too late for a queue whose consumers do 10 a second (a 500 second wait) and a false alarm for one that does 5,000 a second. Every scaling change moves the right number.
Age is the delay the caller sees, so the threshold can come from a requirement: for example, page when the oldest message is over 60 seconds, warn at 30. Most hosted brokers publish it, such as the oldest-message age metric in SQS. For others, stamp an enqueue time on each message and compute it.
Age has blind spots. A single stuck message at the head of a strictly ordered queue raises age while the rest flows, so pair it with a throughput graph. And an empty queue has no age, so also alert if consumers stop completing work at all. I would add a separate alarm for the dead-letter queue.
Sources
- Amazon Web Services documentation (2024). Available CloudWatch metrics for Amazon SQS.
- Mor Harchol-Balter (2013). Performance Modeling and Design of Computer Systems.