Muhammad Muiz Ather
Muhammad Muiz Ather

Reputation: 33

How Can I setup Cloudwatch Alarms on SNS Retry and DLQ Entry?

How can I setup a cloudwatch alarm which should trigger when a SNS topic message is being retried or when there is an entry in my dead letter queue?

Both AWS console setup or cloudformation documentation should be helpful.

I am trying to setup using cloudformation. But I need something as a documentation to create alarms and link them with DLQ/SNS Retries. Any documentation or help is appreciated.

Upvotes: 0

Views: 101

Answers (1)

Kat Lim Ruiz
Kat Lim Ruiz

Reputation: 2562

I haven't configured SNS DLQ, but I did for SQS and DLQ.

    TheDLQ:
      Type: AWS::SQS::Queue
      Properties:
        QueueName: the_queue_dlq
    TheQueue:
      Type: AWS::SQS::Queue
      Properties:
        QueueName: the_queue
        RedrivePolicy:
          deadLetterTargetArn: !GetAtt TheDLQ.Arn
          maxReceiveCount: 3

And then you can create an alarm that is triggered by any item in the DLQ

                TheDlqAlarm: {
                    Type: "AWS::CloudWatch::Alarm",
                    Properties: {
                        AlarmName: `TheDlqAlarm`,
                        AlarmActions: ...,
                        TreatMissingData: missing,
                        EvaluationPeriods: 1,
                        DatapointsToAlarm: 1,
                        Period: 1,
                        Namespace: "AWS/SQS",
                        MetricName: "ApproximateNumberOfMessagesVisible",
                        Dimensions: [{ Name: "QueueName", Value: "the_queue_dlq" }],
                        Statistic: "Sum",
                        ComparisonOperator: "GreaterThanThreshold",
                        Threshold: 0,
                    },
                },

Upvotes: 0

Related Questions