Elastic Load Balancing
Developer Guide (API Version 2012-06-01)
« 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...

Monitor Your Load Balancer Using Amazon CloudWatch

Elastic Load Balancing provides data to Amazon CloudWatch about your load balancers and your back-end application instances. The Amazon CloudWatch service collects the data and presents it as readable, near real-time metrics. This metric variable is represented by Amazon CloudWatch as a time-ordered set of data points. Each data point has an associated time stamp and (optionally) a unit of measurement. You can request one or more data points or request an aggregated set of data points called a statistics set. For example, you might monitor the number of unhealthy instances behind your load balancer in an Availability Zone over a specified time period.

One reason for monitoring metrics in Amazon CloudWatch is to verify that your system is behaving as you expect. If an individual metric goes outside what you consider an acceptable range, you will probably want to be notified. To receive such notification, you can create an alarm in Amazon CloudWatch. A CloudWatch alarm watches over a specified metric and initiates an action if the metric goes outside of the specified range. An action can be a notification sent to you.

This section defines the metrics that Elastic Load Balancing sends to Amazon CloudWatch. It also explains how to view the metrics, and how you can set alarms when a metric meets a condition that you specify.

For information about Amazon CloudWatch, go to Introduction to Amazon CloudWatch.

Available Metrics

Elastic Load Balancing sends metrics and dimensions for all load balancers to Amazon CloudWatch. By default, Amazon CloudWatch uses these metrics to provide detailed monitoring of the load balancers. You do not need to specifically enable detailed monitoring.

Note

Elastic Load Balancing only emits Amazon CloudWatch metrics when requests are flowing through the load balancer. If there are no requests or data for a given metric, the metric will not be reported to CloudWatch.

If there are requests flowing through the load balancer, Elastic Load Balancing will measure and send metrics for that load balancer in 60-second intervals.

Elastic Load Balancing Metrics

The following Elastic Load Balancing metrics are available from Amazon CloudWatch.

The HTTP response code metrics reflect the count of Elastic Load Balancing response codes that are sent to clients within a given time period. If no response codes in the category 2XX-5XX range are sent to clients within the given time period, values for these metrics will not be recorded in CloudWatch.

MetricDescription
Latency

Time elapsed after the request leaves the load balancer until it receives the corresponding response.

Units: Seconds

Valid Statistics: Minimum, Maximum, Average, and Count

RequestCount

The number of requests handled by the load balancer.

Units: Count

Valid Statistics: Sum

HealthyHostCount

The number of healthy Amazon EC2 instances registered with the load balancer in a specified Availability Zone. Hosts that have not failed more health checks than the value of the unhealthy threshold are considered healthy. When evaluating this metric, the dimensions must be provided for LoadBalancerName and AvailabilityZone. The metric represents the count of healthy instances in the specified Availability Zone. Instances may become unhealthy due to connectivity issues, health checks returning non-200 responses (in the case of HTTP or HTTPS health checks), or timeouts when performing the health check. To get the total count of all healthy hosts, this metric must be retrieved for each registered Availability Zone and then all the metrics need to be added together.

Units: Count

Valid Statistics: Minimum, Maximum, and Average

UnHealthyHostCount

The number of unhealthy Amazon EC2 instances registered with the load balancer in a specified Availability Zone. Hosts that have failed more health checks than the value of the unhealthy threshold are considered unhealthy. When evaluating this metric, the dimensions must be provided for LoadBalancerName and AvailabilityZone. The metric represents the count of unhealthy instances in the specified Availability Zone. Instances may become unhealthy due to connectivity issues, health checks returning non-200 responses (in the case of HTTP or HTTPS health checks), or timeouts when performing the health check. To get the total count of all unhealthy hosts, this metric must be retrieved for each registered Availability Zone and then all the metrics need to be added together.

Units: Count

Valid Statistics: Minimum, Maximum, and Average

HTTPCode_ELB_4XX

Count of HTTP response codes generated by Elastic Load Balancing that are in the 4xx (client error) series.

Units: Count

Valid Statistics: Sum

HTTPCode_ELB_5XX

Count of HTTP response codes generated by Elastic Load Balancing that are in the 5xx (server error) series. Elastic Load Balancing may generate 5xx errors if no back-end instances are registered, no healthy back-end instances, or the request rate exceeds Elastic Load Balancing's current available capacity. This response count does not include any responses that were generated by back-end instances.

Units: Count

Valid Statistics: Sum

HTTPCode_Backend_2XX

Count of HTTP response codes generated by back-end instances that are in the 2xx (success) series.

Units: Count

Valid Statistics: Sum

HTTPCode_Backend_3XX

Count of HTTP response codes generated by back-end instances that are in the 3xx (user action required) series.

Units: Count

Valid Statistics: Sum

HTTPCode_Backend_4XX

Count of HTTP response codes generated by back-end instances that are in the 4xx (client error) series. This response count does not include any responses that were generated by Elastic Load Balancing.

Units: Count

Valid Statistics: Sum

HTTPCode_Backend_5XX

Count of HTTP response codes generated by back-end instances that are in the 5xx (server error) series. This response count does not include any responses that were generated by Elastic Load Balancing.

Units: Count

Valid Statistics: Sum

Dimensions for Elastic Load Balancing Metrics

To refine the metrics returned by a query, you can use the dimensions for Elastic Load Balancing that are listed in the table in this section. For example, with the HealthyHostCount metric, you can use the dimensions LoadBalancerName and AvailabilityZone to get the average number of healthy instances behind the specified load balancer within the specified Availability Zone for a given period of time. Alternatively, it may be useful to track the minimum number of healthy hosts or the maximum number of unhealthy hosts to better understand how the health and the count of backend instances change over time.

Elastic Load Balancing data can be aggregated along any of the following dimensions shown in the following table.

Dimension

Description

LoadBalancerName

Limits the metric data to Amazon EC2 instances that are connected to the specified load balancer.

AvailabilityZone

Limits the metric data to load balancers in the specified Availability Zone.

View Metrics

You can view the CloudWatch metrics for your Elastic Load Balancing load balancers directly in the EC2 console’s Load Balancer page. The load balancer metrics are displayed as monitoring graphs. The following metrics are available in the EC2 console:

  • Average Latency

  • Sum Requests

  • Sum ELB HTTP 4XXs

  • Sum ELB HTTP 5XXs

  • Sum HTTP 2XXs

  • Sum HTTP 4XXs

  • Sum HTTP 5XXs

To view the metrics from your load balancer

  1. Sign in to the AWS Management Console and open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. On the Amazon EC2 console Getting Started page, in the EC2 Dashboard pane, under NETWORK & SECURITY, click Load Balancers.

  3. On the Load Balancers page, select the check box next to your load balancer.

    The bottom pane displays the details of your load balancer.

  4. Click the Monitoring tab.

    The bottom pane displays the graphs of metrics sent by Elastic Load Balancing for the selected load balancer.

  5. If you want to filter the results by time, select the time range in the Time Range drop-down box.

    Monitoring Tab

  6. Click on an individual graph to get a larger view of the individual metric.

The my-test-loadbalancer load balancer used in this example is inactive and is used for display purposes only. The monitoring graphs will show data points if the load balancer is active and receiving requests.

You can also view metrics for your load balancer using the Amazon CloudWatch console, command line interface (CLI), or the Query API. For information on using the CloudWatch console to view metrics, see Viewing Your AWS Metrics with Amazon CloudWatch. To view metrics using the command line interface, use the mon-list-metrics command. To view metrics using the Query API, use the ListMetrics action.

Create Alarms

An alarm watches a single metric over a time period you specify. Depending on the value of the metric relative to a threshold that you define, the alarm can send one or more notifications to an Amazon Simple Notification Service (Amazon SNS) topic. Amazon SNS is a web service that enables applications, end users, and devices to instantly send and receive notifications. For more information, see Get Started with Amazon SNS.

An alarm will send notifications to Amazon SNS when the specified metric reaches the defined range and remains in that range for a specified period of time. An alarm has three possible states:

  • OK—This is the state the alarm is in when the value of the metric remains within the range you’ve specified.

  • ALARM—This is the state the alarm goes to when the value of the metric goes out of the range you’ve specified and remains outside of the range for a specified time duration.

  • INSUFFICIENT_DATA—When the alarm is in this state, it either means that the metric is not yet available or not enough data is available for the metric to determine the alarm state.

Whenever the state of an alarm changes, Amazon CloudWatch uses Amazon SNS to send a notification to the email addresses that you specify.

You can create alarms for your load balancer using either the Elastic Load Balancing wizard in the EC2 console or the Amazon CloudWatch console. This section walks you through the steps for creating an alarm using the Elastic Load Balancing wizard. For information on creating a load balancer alarm using the Amazon CloudWatch console, see Send Email Based on Load Balancer Alarm.

To create an alarm for your load balancer

  1. Sign in to the AWS Management Console and open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. On the Amazon EC2 console Getting Started page, in the EC2 Dashboard pane, under NETWORK & SECURITY, click Load Balancers.

  3. On the Load Balancers page, select the check box next to the load balancer for which you want to create an alarm.

    The bottom pane displays the details of your load balancer.

  4. On the Monitoring tab in the bottom pane, click Create Alarm.

  5. In the Create Alarm dialog box, set the criteria for your alarm. In this example, we’ll set an alarm if the load balancer's latency is above 120 seconds for 1 consecutive period of 5 minutes.

  6. The check box next to Send a notification to is selected by default.

    If you've already created a SNS topic and want to use it, select your topic from the drop-down box. Skip the next step.

    If you do not have a SNS topic, click create topic.

  7. In the With these recipients box, enter the email addresses of the recipients you want to notify. You can enter up to 10 email addresses, each separated by a comma.

    Note

    If your email recepients have not yet been subscribed to the SNS topic, each email recipient will receive an email from Amazon SNS with a link to confirm their subscription to the SNS topic. If they do not confirm subscription, they will not receive future email Alarm notifications.

  8. Configure the threshold for your alarm.

    1. In the Whenever boxes, select Average and Latency.

    2. In the Is boxes, define the threshold for the alarm by selecting > and entering 120.

    3. In the For at least boxes, enter 1 and then select 5 minutes, or you can define your own evaluation period.

      Note

      A shorter period creates a more sensitive alarm. A longer period can mitigate brief spikes in a metric.

    4. In Name this alarm, a name is automatically generated for you. Click Edit if you want to change the name.

      Important

      You cannot modify the name after you create the alarm.

      Create Alarm

  9. Click Create Alarm.

    Create Alarm

  10. Click Close.

After you create the alarm, you can use the Monitoring tab to view a summary of alarms that have been set for that load balancer. From there, you can also edit the alarm.