Amazon CloudWatch
Developer Guide (API Version 2010-08-01)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

Send Email Based on Load Balancer Alarm

This scenario walks you through how to use the AWS Management Console or the command line tools to set up an Amazon SNS notification and configure an alarm that monitors load balancer latency exceeding 100 ms.

AWS Management Console

The Create Alarm Wizard steps you through the process of creating an alarm.

To open the Create Alarm Wizard

  1. Open the Amazon CloudWatch console at https://console.aws.amazon.com/cloudwatch/.

  2. In the Navigation pane, click Alarms.

    The Your CloudWatch Alarms page opens.

    Console Create Alarm Button
  3. Click Create Alarm.

    The SELECT METRIC page of the Create Alarm Wizard opens.

    Console Create Alarm Wizard Step 1

To select a metric for your alarm

  1. Select ELB: Load Balancer Metrics from the Viewing drop-down list.

    The metrics available for individual instances appear in the Metrics pane.

  2. Select a row that contains Latency for a specific load balancer.

    A graph showing average Latency for a single load balancer appears next to the Statistic and Period drop-down lists.

    AWS Management Console Create Alarm Wizard Select Metric.
  3. Select Average from the Statistic drop-down list.

  4. Select 1 Minute from the Period drop-down list.

  5. Click Continue.

    The DEFINE ALARM page of the Create Alarm Wizard opens.

To define the alarm name, description, and threshold

  1. In the Name field, enter the name of the alarm, for example: myHighCpuAlarm.

  2. In the Description field, enter a description of the alarm, for example: Alarm when Latency exceeds 100ms.

  3. Select > in the Define Alarm Threshold drop-down list.

  4. Enter 0.1 in the first Define Alarm Threshold field and 3 in the second field.

    A graphical representation of the threshold appears on the page.

    AWS Management Console Create Alarm Wizard Define Alarm with Values.
  5. Click Continue.

    The CONFIGURE ACTIONS page of the Create Alarm Wizard opens.

    AWS Management Console Create Alarm Wizard Configure Actions.

To configure an email action for an alarm

  1. Select ALARM from the Alarm State drop-down list.

  2. Select Create Email Topic... from the Topic drop-down list.

    Two new fields named Topic and Emails replace the Topic drop-down list.

    AWS Management Console Create Alarm Wizard Configure Email Actions.
  3. In the Topic field, enter a descriptive name for the Amazon SNS topic, for example: myHighCpuAlarm.

  4. In the Emails field, enter a comma-separated list of email addresses to be notified when the alarm changes to the ALARM state.

  5. Click ADD ACTION.

    The action is saved and the ADD ACTION button becomes a REMOVE button.

  6. Click Continue.

    The REVIEW window of the Create Alarm Wizard opens.

    AWS Management Console Create Alarm Wizard Configure Email Actions.

Now that you have defined the alarm and configured the alarm's actions, you are ready to review the settings and create the alarm by following the steps in the next procedure.

To review the alarm settings and create the alarm

  1. Review the alarm settings presented in the REVIEW page of the Create Alarm Wizard.

    You can make changes to the settings using the Edit Definition, Edit Metric, or Edit Actions links.

  2. Click Create Alarm to complete the alarm creation process.

    A confirmation dialog box opens.

    AWS Management Console Create Alarm Wizard Configure Email Actions.
  3. Click Close.

    Your alarm is created.

Command Line Tools

To send an Amazon SNS email message when LoadBalancer Latency Exceeds 100 milliseconds

  1. Create an Amazon SNS topic. See instructions for creating an Amazon SNS topic in Set Up Amazon SNS

  2. Create the alarm.

    Prompt>mon-put-metric-alarm  --alarm-name lb-mon --alarm-description "Alarm when Latency exceeds 100ms" --metric-name Latency --namespace AWS/ELB --statistic Average  --period 60 --threshold 100 --comparison-operator GreaterThanThreshold  --dimensions LoadBalancerName=my-server  --evaluation-periods 3 --alarm-actions arn:aws:sns:us-east-1:1234567890:my-topic --unit Milliseconds

    Amazon CloudWatch returns the following:

    OK-Created Alarm
  3. Test the alarm.

    • Force an alarm state change to ALARM:

      Prompt>mon-set-alarm-state  --state OK
      Prompt>mon-set-alarm-state  --state ALARM

      Amazon CloudWatch returns the following:

      OK-Set alarm state value
    • Check that an email has been received.