Metrics and Alarms

Metrics are data about the performance of your systems. By default, many services provide free metrics for resources (such as Amazon EC2 instances, Amazon EBS volumes, and Amazon RDS DB instances). You can also enable detailed monitoring for some resources, such as your Amazon EC2 instances, or publish your own application metrics. Amazon CloudWatch can load all the metrics in your account (both AWS resource metrics and application metrics that you provide) for search, graphing, and alarms.

  1. Browse Metrics - Let’s get familiar with how to locate and work with CloudWatch metrics.

    • In your AWS Console, navigate to CloudWatch via the Services menu or Click Here.
    • In the left hand navigation menu, click All Metrics under the metrics section

    You should see a screen similar to the one below. CWMetrics

    • From here you can dive into a specific Namespace to see what metrics are available for that service.
    • Let’s click on EC2, you should see a screen similar to the one below. CWDimensions
    • Now we can see the different dimensions available for the specific Namespace. Dimensions are ways you can group, filter, or slice metrics. In our example we can use a specific EC2 instance as a dimension, or we can use the Auto Scaling Group dimension which will aggregate all EC2 instances for us. Let’s click on the option for Per-Instance Metrics.
    • You should see the default metrics that AWS provides for the EC2 instances in your account and region. If you are not using a new account for this lab you may see many entries here.
    • Next, we will find the CPU metrics for our instances. In the Search bar enter CPUUtilization and select the 2 instances name “Lab App host”
    • Your screen should look similar to the image below. Spend some time to familiarize yourself with the different aspects of this view: CWGraph
  2. Create CPU Alarm - Now that we know the basics, we’ll create a simple alarm on CPU utilization

    • On the left side navigation menu, expand Alarms and click the selection for All Alarms.
    • Click on the orange button named Create Alarm
    • Click Select Metric, then click EC2 under the AWS Namespaces section, then click Per Instance Metrics
    • In the search bar, type CPUUtilization
    • Look for the results containg the Instance Name of Lab App Host, there should be 2 in the list. Select one of the entries and click the button name Select Metrics.
    • In specify metric and conditions, keep all defaults but set the the threshold value to 50
    • Expand the Additional configuration section, change the Datapoints to alrarm setting to alert on 2 out of 2 datapoints. This will trigger the alarm whenever CPU Utilitzation averages above 50% for 10 minutes. Your screen should look similar to below. cw-alarm1 cw-alarm2
    • Click the button Next
    • Now we will configure the action taken when the Alarm is triggered. For now we’ll simply send an email.
    • Leave the Alarm state trigger as In alarm.
    • Click the radio button to Create a new topic.
    • Change the topic name to CPUAlerts, enter the email you wish to recieve the alert to in the next field.
    • Click the button to Create Topic, the new topic should now be select in the Send a notification… field. Click Next.
    • Add the name CPU Alarm #1 and decription CPUAlarm for OpsLab.
    • Verify the details, the click the button to Create Alarm.
    • As part of setting up the new SNS topic, you will need to confirm the subscription. Check your email for a message from AWS Notifications with the subject “AWS Notification - Subscription Confirmation”. Click the Confirm Subscription link from this email.
    • Follow the same steps to create an Alarm for the 2nd EC2 instance, except re-use the SNS created for the first instance.
    • In the alarms section, you should now see 2 alarms for the CPU Alerts you just setup: cw-alarm3