Create a Metric Alarms

A metric alarm watches a single CloudWatch metric or the result of a math expression based on CloudWatch metrics. The alarm performs one or more actions based on the value of the metric or expression relative to a threshold over a number of time periods. The action can be an Amazon EC2 action, an Amazon EC2 Auto Scaling action, or a notification sent to an Amazon SNS topic.

Creating a Metric Alarm

Go to your CloudWatch Alarms Console.

  1. Click on Create Alarm.
  2. Click Select Metric.
  3. This will take you to the Metrics home page, where you will see all the Namespaces available in the account. Select the MonitoringApp namespace

alarm-1

  1. Select FunctionName, FunctionVersion, operation, service dimension and select the SuccessfulGetItem metric we created in the previous exercise.

alarm-2 alarm-3

  1. Enter the threshold value (for example, 1) that you want the metric data to be monitored. Notice that Static option is selected by default, which means we will be setting a static value as the threshold to be monitored.

  2. Expand Additional configuration where you can indicate how many occurences of the breach qualifies for the alarm to be triggered. Set the values to 1 out of 5, which will make the alarm get triggered if there has been 1 breaches in 5 evaluation periods. Notice the message at the top of the graph describing the setting as This alarm will trigger when the blue line goes above the red line for 1 datapoints within 25 minutes.

  3. Click Next.

  4. In the Configure actions screen, you can set what action you want to take when the alarm changes to different states such as

    • In alarm
    • OK
    • Insufficient data

The available options for actions include, - Send a notification to an SNS topic - Take an Auto scaling action - EC2 action if the metric is from an EC2 instance

  1. Select Create a new topic to create a new SNS topic to send the notification to and provide your email address.

alarm-4

  1. Name it my_observability_topic, fill your e-mail address and click Create topic.
  2. Click Next.
  3. Name it My Observability Alarm.
  4. Click Next.

alarm-4

  1. Review your settings and click Create alarm.
  2. Open you e-mail inbox and confirm your SNS topic subscription alarm-4

If you don’t confirm your e-mail subscription, you will not receive any notification emails for triggered alarms. Always remember to also check your spam folder.