Salta al contenuto

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

posta 2 mesi fa95 visualizzazioni
2 Risposte
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

con risposta 2 mesi fa
ESPERTO
verificato 2 mesi fa
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.)
con risposta 2 mesi fa
AWS
ESPERTO
verificato 2 mesi fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.