내용으로 건너뛰기

Alarm when a new message in DLQ

0

I have a SQS and DLQ and when a retry is failed in SQS for 5 count the message is moved to DLQ. Here I need a alarm when a new message comes to DLQ, So how to do that and which metrics in DLQ i need to use for this above scenario

질문됨 2달 전98회 조회
2개 답변
0

To create an alarm that triggers when a new message arrives in your Dead Letter Queue (DLQ), you should use the ApproximateNumberOfMessagesVisible CloudWatch metric for your DLQ. This metric captures all messages currently available in the DLQ, including those moved due to processing failures from your source SQS queue.

Here's how to set up the alarm:

  1. Sign in to the AWS Management Console and open the CloudWatch console.
  2. Choose "Alarms" and then "Create Alarm".
  3. In the "Select Metric" section, browse for "SQS" metrics.
  4. Select "Queue Metrics" and find your DLQ by name.
  5. Choose the ApproximateNumberOfMessagesVisible metric for your DLQ.
  6. In the "Define Alarm" section:
  • Set a name and description for your alarm
  • Set the threshold to be greater than 0 (or a baseline number if your DLQ normally has some messages)
  • Configure the period (e.g., 1 minute)
  • Set the evaluation periods and datapoints to alarm (e.g., 1 out of 1)
  • Choose the statistic (typically "Sum" for message counts)
  1. Set up notifications by selecting an existing Amazon SNS topic or creating a new one.
  2. Create the alarm.

The ApproximateNumberOfMessagesVisible metric is more appropriate than NumberOfMessagesSent because it specifically captures messages that are currently in the queue, including those that were moved to the DLQ as a result of failed processing attempts in your source SQS queue.
Sources
Amazon SNS dead-letter queues - Amazon Simple Notification Service
Creating CloudWatch alarms for Amazon SQS metrics - Amazon Simple Queue Service

답변함 2달 전
전문가
검토됨 2달 전
0

If you want to get alerted when a message hits your SQS DLQ, you should monitor the metric:

ApproximateNumberOfMessagesVisible in CloudWatch

This number goes up as soon as a message lands in the DLQ and is waiting to be read. So the moment retries fail on the main queue and the message is moved to DLQ — this value will become 1 (or more).

  1. What You Should Do
  2. Open CloudWatch → Alarms → Create Alarm
  3. Pick the DLQ queue and the metric:
  4. ApproximateNumberOfMessagesVisible
  5. Set the threshold like:
  6. Whenever >= 1
  7. Optional: for 1 out of 1 evaluation periods (for near instant detection)
  8. Add an SNS notification (email, Slack, Lambda, etc.)
답변함 2달 전
AWS
전문가
검토됨 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠