Monitoring Amazon SNS using Amazon CloudWatch metrics

Amazon SNS automatically collects and sends various metrics about message deliveries to Amazon CloudWatch. You can view these metrics and assign them with alarms to alert you, in case a message delivery rate drops beyond a certain threshold. You can additionally view the message delivery logs, as well using the CloudWatch Logs page:

  1. To get started, first ensure that you have assigned an IAM role that allows SNS to write SMS delivery logs over to CloudWatch. To do so, from the navigation pane, select the Text messaging (SMS) option.
  2. Next, from the Manage text messaging preferences option, ensure that you have a valid IAM role provided under the IAM role for CloudWatch Logs access field.
  3. Once the IAM role is created, log in to your CloudWatch dashboard by selecting https://console.aws.amazon.com/cloudwatch/home.
  4. Here, select the Logs option from the navigation pane to bring up the CloudWatch Log Groups page. You should see a default Log Group created here, by the name of DirectPublishToPhoneNumber.
  1. Select the Log Group to view the SMS delivery log messages. The logs will either show a SUCCESS or FAILURE in the status field, as shown in the following screenshot:
  1. You can additionally create and associate CloudWatch alarms with your monitored SNS metrics. To do so, from the CloudWatch dashboard, select the Metrics option.
  2. From the All metrics tab, filter and select the SNS option.
  3. Based on the requirements, you can now select between viewing the metrics based on the PhoneNumber, or Country, SMSType, and so on. In this case, we have selected the PhoneNumber option to view the NumberOfNotificationsFailed and NumberOfNotificationsDelivered metrics.
  4. Next, select the Graphed metrics tab to view the two metrics and their associated actions. Using the Actions column, select the Create alarm option for the metric that you wish to monitor.
  5. Fill in the respective details and configure the alarm's threshold values based on your requirements. Once completed, click on Create Alarm to complete the process.

In this way, you can leverage Amazon CloudWatch to create and view logs and alerts generated by the SNS service. In the next section, we will be exploring and learning a bit about the second part of the AWS messaging services: SQS.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset