Set CloudWatch Alarms for Amazon SQS Metrics
CloudWatch allows you to trigger alarms when a threshold is met for a metric. For example,
you could set an alarm for the
NumberOfMessagesSent metric so that
when the number of messages exceeds a specified limit over a specified time period, then
an email notification could be sent to inform you of the event.
To set an alarm (CloudWatch console)
Sign in to the AWS Management Console and open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
In the navigation pane, choose Alarms, and then choose Create Alarm. The Create Alarm dialog box displays.
On the Select Metric page, choose Browse Metrics, SQS:
For SQS > Queue Metrics, choose (check) the box that you want to set an alarm for the combination of QueueName and Metric Name. (For a list of available metrics, see Available CloudWatch Metrics for Amazon SQS). For example, choosing (checking) the box for MyQueue, NumberOfMessagesSent sets an alarm based on the number of messages sent to the
Choose Next. The Define Alarm page displays.
For Alarm Threshold, fill in the Name and Description boxes. For is, for, Period, and Statistic, specify the conditions for the alarm. For example, let's say you chose (checked) the box for MyQueue, NumberOfMessagesSent on the Select Metric page, and you want to alarm when more than 100 messages are sent in any hour to the
MyQueuequeue. You'd then set the following:
Set is to > 100.
Set for to 1.
Set Period to 1 Hour.
Set Statistic to Sum.
For Actions and Whenever this alarm, choose State is ALARM. For Send notification to, if you want CloudWatch to send you an email when the alarm state is reached, either select an existing Amazon SNS topic or choose New list. If you choose New list, you can set the name and list comma-separated email addresses for a new topic. This list will be saved and appear for future alarms.
If you choose New list to create a new Amazon SNS topic, the email addresses must be verified before they'll receive notifications. Emails are sent only when the alarm enters an alarm state. If this alarm state change happens before the email addresses are verified, they won't receive a notification.
Choose Create Alarm. CloudWatch creates the alarm and then displays the alarms list.
For more information, see Creating Amazon CloudWatch Alarms.