0

I am trying to trigger an alarm if message is sent to SQS. However, I see that the CloudWatch metrics indicates that there was a message but no alarm is triggered.

The alarm is currently in INSUFFICIENT_DATA state as well. For testing, I am sending a message via boto3 client.

Below is my CloudFormation Template for SQS and CloudWatch alarm

QueueMessageAlarm:
Type: AWS::CloudWatch::Alarm
Condition: AlarmsEnabled
Properties:
  AlarmDescription: "Alarm if queue message is greater than 0"
  AlarmActions:
    - !Ref SampleNotificationTopic
  Namespace: "AWS/SQS"
  MetricName: "NumberOfMessagesReceived"
  Statistic: "Sum"
  Period: "900"
  EvaluationPeriods: "1"
  Threshold: "0"
  ComparisonOperator: "GreaterThanThreshold"
  Dimensions:
    - Name: "QueueName"
    - Value:
        Fn::GetAtt:
          - "KinesisStreamFileQueue"
          - "QueueName"

KinesisStreamFileQueue:
  Type: AWS::SQS::Queue
  Properties:
    QueueName: "StreamQueue"
Young
  • 419
  • 3
  • 19

2 Answers2

2

I figured out the issue by changing the Dimensions properties for the alarm resource. The resource needs to refer to the arn of the queue, and it was previously getting the url of it

Dimensions:
    - Name: QueueName
      Value: { "Fn::GetAtt": [ "KinesisStreamFileQueue", "QueueName"] }
Young
  • 419
  • 3
  • 19
1

Use the ApproximateNumberOfMessagesVisible metric instead of any "Received" metric.

The downside of using "Received" metrics is that unless you're constantly receiving messages, you're likely to get stuck in INSUFFICIENT_DATA, resulting in alarm issues.

Krease
  • 15,805
  • 8
  • 54
  • 86
  • thanks for looking into it. I figured out the issue by changing the the Dimensions of the Properties. I posted an answer – Young Dec 14 '18 at 21:56