# CloudWatch alarm: SQS ApproximateAgeOfOldestMessage

CloudWatch alarms · Updated 16 November 2026

**Short answer:** Alarm on AWS/SQS ApproximateAgeOfOldestMessage per QueueName with the Maximum over 60 seconds, firing when it is at or above your threshold for 15 of 15 minutes. Set the threshold to about 1.5 times the longest time a message should normally wait and be processed, so the alarm means work is genuinely falling behind or a message is stuck.

## What the metric measures

`ApproximateAgeOfOldestMessage` is how long, in seconds, the oldest message still in the queue has been there. It answers the question users care about, "how late is the work?", better than queue depth does: 10,000 messages that are 3 seconds old are fine, while 5 messages that are 2 hours old are not.

Two very different problems raise it:

- **Consumers too slow or too few.** The age climbs steadily together with [ApproximateNumberOfMessagesVisible](https://cloudconsole.dev/alarms/sqs-approximatenumberofmessagesvisible).
- **A poison message.** One message keeps failing, returns to the queue after each visibility timeout, and grows old while everything else flows. Depth stays low, age climbs in a straight line. Without a dead-letter queue, it stays until the retention period deletes it.

For queues with a redrive policy, a message that is retried until it moves to the DLQ stops counting once it leaves; the age then drops back, which is a sign the DLQ is doing its job.

## Recommended alarm settings

| Setting | Recommended value |
|---|---|
| Namespace | `AWS/SQS` |
| Metric | `ApproximateAgeOfOldestMessage` |
| Dimensions | QueueName |
| Statistic | Maximum |
| Threshold | Depends on your situation (see method below) |
| Period | 60 seconds |
| Datapoints to alarm | 15 |
| Evaluation periods | 15 |
| Comparison operator | `GreaterThanOrEqualToThreshold` |

## Choosing the threshold

1. **Measure normal:** chart the Maximum for two weeks, including peaks and deploys.
2. **Work out the expected worst case:** the longest acceptable queueing time plus processing time. For a worker that normally clears the queue within 2 minutes at peak and takes up to 60 seconds per message, that is about 180 seconds.
3. **Add 50%:** 270 seconds.
4. **Check against retention:** the threshold must be far below the queue's `MessageRetentionPeriod`, or messages are deleted before you hear about them.

The 15-minute window ignores short bursts; lower it for queues where minutes of delay matter to users.

## Create the alarm

```
aws cloudwatch put-metric-alarm \
  --alarm-name sqs-orders-oldest-message-age \
  --alarm-description "Oldest message in orders older than 270s for 15 minutes" \
  --namespace AWS/SQS \
  --metric-name ApproximateAgeOfOldestMessage \
  --dimensions Name=QueueName,Value=orders \
  --statistic Maximum \
  --period 60 \
  --evaluation-periods 15 \
  --datapoints-to-alarm 15 \
  --threshold 270 \
  --comparison-operator GreaterThanOrEqualToThreshold \
  --alarm-actions arn:aws:sns:eu-west-2:123456789012:oncall-alerts
```

## When it fires

1. **Depth or poison?** Check visible messages. High depth means capacity; low depth with high age means a stuck message.
2. **Capacity:** scale consumers (more tasks, higher Lambda concurrency or batch size), and check for a slow downstream dependency that is holding each message longer.
3. **Poison message:** look in consumer logs for the same message ID failing repeatedly. Configure a redrive policy with a sensible `maxReceiveCount` so such messages move to a DLQ; see [set-queue-attributes](https://cloudconsole.dev/cli/sqs-set-queue-attributes).
4. **Consumers stopped?** If `NumberOfMessagesReceived` is zero, the consumer is down, misconfigured, or its event source mapping is disabled.

## Questions

### How do I alarm on SQS queue size?

Use ApproximateNumberOfMessagesVisible for backlog size. Age of oldest message is often the better alarm because it reflects delay directly, regardless of volume.

### How do I set a CloudWatch alarm on an SQS dead-letter queue?

Alarm on ApproximateNumberOfMessagesVisible for the DLQ with GreaterThanThreshold 0, so any message landing there notifies you. Do not use NumberOfMessagesSent on a DLQ, because messages moved there by a redrive policy are not counted in it.

### Why does the oldest message age keep growing with an almost empty queue?

Usually a single message fails repeatedly and is returned to the queue each time. A dead-letter queue with maxReceiveCount moves it aside after a few attempts.

## When this happens away from your desk

Queue age is one of the clearest "users are waiting" signals, and it often climbs outside working hours. CloudConsole, a phone app for AWS, is built to show this alarm with queue depth on the same screen on your phone.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Recommended alarms (Amazon CloudWatch User Guide)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html)
- [Available CloudWatch metrics for Amazon SQS](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-available-cloudwatch-metrics.html)
- [Using dead-letter queues in Amazon SQS](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html)

## Related

- [CloudWatch alarm: SQS ApproximateNumberOfMessagesVisible](https://cloudconsole.dev/alarms/sqs-approximatenumberofmessagesvisible)
- [CloudWatch alarm: SQS ApproximateNumberOfMessagesNotVisible](https://cloudconsole.dev/alarms/sqs-approximatenumberofmessagesnotvisible)
- [How to redrive messages from an SQS dead-letter queue](https://cloudconsole.dev/how-to/redrive-sqs-dead-letter-queue)
- [How to check SQS queue size](https://cloudconsole.dev/how-to/check-sqs-queue-depth)
- [aws sqs set-queue-attributes](https://cloudconsole.dev/cli/sqs-set-queue-attributes)
- [CloudWatch alarm: SQS NumberOfMessagesSent (producer stopped)](https://cloudconsole.dev/alarms/sqs-numberofmessagessent)

---

Source: https://cloudconsole.dev/alarms/sqs-approximateageofoldestmessage

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
