Reputation: 419
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"
Upvotes: 0
Views: 2419
Reputation: 419
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"] }
Upvotes: 2
Reputation: 16215
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.
Upvotes: 1