I tried to create a AWS Alarm to watch the SQS. If the queue has more than 1 message for 2 minutes, I want to create an alarm to trigger a policy. I used this command to create the alarm:
aws cloudwatch put-metric-alarm --alarm-name alarmName --metric-name ApproximateNumberOfMessagesVisible --namespace "AWS/SQS" --statistic Average --period 60 --evaluation-periods 2 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --dimensions "Name=QueueName,Value=QueueName" "Name=AutoScalingGroupName,Value=asg-name" --alarm-actions "<arn:batch-upscale-policy>" --actions-enable
I can see the alarm in the AWS console, but it's stuck in the INSUFFICIENT_DATA
state. How can I fix it?
Here I'm to listen to queues in other AWS Account. Is it possible??!
What you are seeing is normal, if you don't already have a process running that is polling the queue. You have to have something running that will at least periodically poll the queue, and the insufficient data condition should then clear itself. SQS sends nothing to cloudwatch if the queue has no producers or consumers for approximately 6 hours.
The metrics you configure with CloudWatch for your Amazon SQS queues are automatically collected and pushed to CloudWatch every five minutes. These metrics are gathered on all queues that meet the CloudWatch guidelines for being active. A queue is considered active by CloudWatch for up to six hours from the last activity (i.e., any API call) on the queue.