Amazon Simple Queue Service
Developer Guide (API Version 2012-11-05)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

Monitoring Amazon SQS with CloudWatch

Amazon SQS and CloudWatch are integrated so you can use CloudWatch to easily collect, view, and analyze metrics for your Amazon SQS queues. Once you have configured CloudWatch for Amazon SQS, you can gain better insight into the performance of your Amazon SQS queues and applications. For example, you can monitor the NumberOfEmptyReceives metric to make sure that your application isn't spending too much of its time polling for new messages. You can also set an alarm to send you an email notification if a specified threshold is met for an Amazon SQS metric, such as NumberOfMessagesReceived. For a list of all the metrics that Amazon SQS sends to CloudWatch, see Amazon SQS Metrics.

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.

Note

There is no charge for the Amazon SQS metrics reported in CloudWatch; they are provided as part of the Amazon SQS service.

Access CloudWatch Metrics for Amazon SQS

You can monitor metrics for Amazon SQS using the CloudWatch console, CloudWatch's own command line interface (CLI), or programmatically using the CloudWatch API. The following procedures show you how to access the metrics using these different options.

To view metrics using the CloudWatch console

  1. Sign in to the AWS Management Console and open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.

  2. Click View Metrics.

  3. From the Viewing drop-down menu select SQS: Queue Metrics to show the available metrics for each queue.

  4. Click a specific metric in the MetricName column to see more detail, such as a graph of the data collected.

To access metrics from the CloudWatch CLI

To access metrics from the CloudWatch API

Set CloudWatch Alarms for Amazon SQS Metrics

CloudWatch also allows you to set alarms when a threshold is met for a metric. For example, you could set an alarm for the metric, NumberOfEmptyReceives, so that when your specified threshold number is met within the sampling period, then an email notification would be sent to inform you of the event.

To set alarms using the CloudWatch console

  1. Sign in to the AWS Management Console and open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.

  2. Click Alarms, and then click the Create Alarm button. This launches the Create Alarm Wizard.

  3. Scroll through the Amazon SQS metrics to locate the metric you want to place an alarm on. Select the metric to create an alarm on and click Continue.

  4. Fill in the Name, Description, Threshold, and Time values for the metric, and click Continue.

  5. Choose Alarm as the alarm state. If you want CloudWatch to send you an email when the alarm state is reached, either select a preexisting Amazon SNS topic or click Create New Email Topic. If you click Create New Email Topic, you can set the name and email addresses for a new topic. This list will be saved and appear in the drop-down box for future alarms. Click Continue.

    Note

    If you use Create New Email Topic to create a new Amazon SNS topic, the email addresses must be verified before they will 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 will not receive a notification.

  6. At this point, the Create Alarm Wizard gives you a chance to review the alarm you're about to create. If you need to make any changes, you can use the Edit links on the right. Once you're satisfied, click Create Alarm.

For more information about using CloudWatch and alarms, see the CloudWatch Documentation

Amazon SQS Metrics

Amazon SQS sends the following metrics to CloudWatch.

MetricDescription

NumberOfMessagesSent

The number of messages added to a queue.

Units: Count

Valid Statistics: Sum

SentMessageSize

The size of messages added to a queue.

Units: Bytes

Valid Statistics: Minimum, Maximum, Average, and Count

NumberOfMessagesReceived

The number of messages returned by calls to the ReceiveMessage API action.

Units: Count

Valid Statistics: Sum

NumberOfEmptyReceives

The number of ReceiveMessage API calls that did not return a message.

Units: Count

Valid Statistics: Sum

NumberOfMessagesDeleted

The number of messages deleted from the queue.

Units: Count

Valid Statistics: Sum

ApproximateNumberOfMessagesDelayed

The number of messages in the queue that are delayed and not available for reading immediately. This can happen when the queue is configured as a delay queue or when a message has been sent with a delay parameter.

Units: Count

Valid Statistics: Average

ApproximateNumberOfMessagesVisible

The number of messages available for retrieval from the queue.

Units: Count

Valid Statistics: Average

ApproximateNumberOfMessagesNotVisible

The number of messages that are "in flight." Messages are considered in flight if they have been sent to a client but have not yet been deleted or have not yet reached the end of their visibility window.

Units: Count

Valid Statistics: Average