Menu
Auto Scaling
User Guide

Monitoring Your Auto Scaling Groups and Instances Using Amazon CloudWatch

Amazon CloudWatch enables you to retrieve statistics as an ordered set of time-series data, known as metrics. You can use these metrics to verify that your system is performing as expected.

Amazon EC2 sends metrics to CloudWatch that describe your Auto Scaling instances. These metrics are available for any EC2 instance, not just those in an Auto Scaling group. For more information, see Instance Metrics in the Amazon EC2 User Guide for Linux Instances.

Auto Scaling groups can send metrics to CloudWatch that describe the group itself. You must enable these metrics.

Auto Scaling Group Metrics

The AWS/AutoScaling namespace includes the following metrics.

MetricDescription
GroupMinSize

The minimum size of the Auto Scaling group.

GroupMaxSize

The maximum size of the Auto Scaling group.

GroupDesiredCapacity

The number of instances that the Auto Scaling group attempts to maintain.

GroupInServiceInstances

The number of instances that are running as part of the Auto Scaling group. This metric does not include instances that are pending or terminating.

GroupPendingInstances

The number of instances that are pending. A pending instance is not yet in service. This metric does not include instances that are in service or terminating.

GroupStandbyInstances

The number of instances that are in a Standby state. Instances in this state are still running but are not actively in service.

GroupTerminatingInstances

The number of instances that are in the process of terminating. This metric does not include instances that are in service or pending.

GroupTotalInstances

The total number of instances in the Auto Scaling group. This metric identifies the number of instances that are in service, pending, and terminating.

Dimensions for Auto Scaling Group Metrics

To filter the metrics for your Auto Scaling group by group name, use the AutoScalingGroupName dimension.

Enable Auto Scaling Group Metrics

When you enable Auto Scaling group metrics, Auto Scaling sends aggregated data to CloudWatch every minute.

To enable group metrics using the console

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. In the navigation pane, choose Auto Scaling Groups.

  3. Select your Auto Scaling group.

  4. On the Monitoring tab, for Auto Scaling Metrics, choose Enable Group Metrics Collection. If you don't see this option, select Auto Scaling for Display.

    Enable Auto Scaling group metrics collection.

To disable group metrics using the console

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. In the navigation pane, choose Auto Scaling Groups.

  3. Select your Auto Scaling group.

  4. On the Monitoring tab, for Auto Scaling Metrics, choose Disable Group Metrics Collection. If you don't see this option, select Auto Scaling for Display.

    Disable Auto Scaling group metrics collection.

To enable group metrics using the AWS CLI

Enable one or more group metrics using the enable-metrics-collection command. For example, the following command enables the GroupDesiredCapacity metric.

aws autoscaling enable-metrics-collection --auto-scaling-group-name my-asg --metrics GroupDesiredCapacity --granularity "1Minute"

If you omit the --metrics option, all metrics are enabled.

aws autoscaling enable-metrics-collection --auto-scaling-group-name my-asg --granularity "1Minute"

To disable group metrics using the AWS CLI

Use the disable-metrics-collection command. For example, the following command disables all Auto Scaling group metrics:

aws autoscaling disable-metrics-collection --auto-scaling-group-name my-asg

Enable Auto Scaling Instance Metrics

You can enable basic or detailed monitoring for the instances in your Auto Scaling group when you create a launch configuration. By default, basic monitoring is enabled when you create the launch configuration using the AWS Management Console and detailed monitoring is enabled when you create the launch configuration using the AWS CLI or an API.

If you have an Auto Scaling group and need to change which type of monitoring is enabled for your Auto Scaling instances, you must create a new launch configuration and update the Auto Scaling group to use this launch configuration.

To enable Auto Scaling instance metrics using the console

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. Create a launch configuration as follows:

    1. In the navigation pane, choose Launch Configurations.

    2. Choose Create launch configuration.

    3. On the first two pages, choose and AMI and an instance type.

    4. On the Configure details page, to enable detailed monitoring, select Enable CloudWatch detailed monitoring. Otherwise, basic monitoring is enabled.

    5. Complete the wizard to create your launch configuration.

  3. Create an Auto Scaling group using this launch configuration as follows:

    1. In the navigation pane, choose Auto Scaling Groups.

    2. Choose Create Auto Scaling group.

    3. On the first page, select Create an Auto Scaling group from an existing launch configuration, select the launch configuration, and then choose Next Step.

    4. Complete the wizard to create your Auto Scaling group.

  4. If you have an existing Auto Scaling group, you can update it to use this launch configuration as follows:

    1. In the navigation pane, choose Auto Scaling Groups.

    2. Select the Auto Scaling group.

    3. On the Details tab, choose Edit.

    4. For Launch Configuration, select the launch configuration.

    5. Choose Save.

    6. From now on, the instances that the Auto Scaling group launches will use the updated monitoring type. However, if you have existing instances in the Auto Scaling group, they maintain the previous monitoring type. You can terminate these instances so that Auto Scaling replaces them, or update each instance individually.

    7. If you have CloudWatch alarms associated with your Auto Scaling group, update each alarm each alarm so that its period matches the monitoring type (300 seconds for basic monitoring and 60 seconds for detailed monitoring).

      If you change from detailed monitoring to basic monitoring but do not update your alarms to match the five-minute data aggregations, they continue to check for statistics every minute and might find no data available for as many as four out of every five periods.

To enable monitoring using the AWS CLI

  1. Use the create-launch-configuration command with the --instance-monitoring option. Set this option to true to enable detailed monitoring or false to enable basic monitoring.

    --instance-monitoring Enabled=true
  2. Use the update-auto-scaling-group command with the --launch-configuration-name option to use this launch configuration.

    --launch-configuration-name my-lc
  3. Use the put-metric-alarm command with the --period option to ensure the period matches the monitoring type (300 seconds for basic monitoring and 60 seconds for detailed monitoring).

    --period 300

View CloudWatch Metrics

You can view the CloudWatch metrics for your Auto Scaling groups and instances using the Amazon EC2 console. These metrics are displayed as monitoring graphs.

Alternatively, you can view these metrics using the CloudWatch console.

To view metrics using the Amazon EC2 console

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. In the navigation pane, choose Auto Scaling Groups.

  3. Select your Auto Scaling group.

  4. Choose the Monitoring tab.

  5. (Optional) To filter the results by time, select a time range from Showing data for.

  6. To view the metrics for your groups, for Display, choose Auto Scaling. To get a larger view of a single metric, select its graph. The following metrics are available for groups:

    • Minimum Group Size — GroupMinSize

    • Maximum Group Size — GroupMaxSize

    • Desired Capacity — GroupDesiredCapacity

    • In Service Instances — GroupInServiceInstances

    • Pending Instances — GroupPendingInstances

    • Standby Instances — GroupStandbyInstances

    • Terminating Instances — GroupTerminatingInstances

    • Total Instances — GroupTotalInstances

  7. To view metrics for your instances, for Display, choose EC2. To get a larger view of a single metric, select its graph. The following metrics are available for instances:

    • CPU Utilization — CPUUtilization

    • Disk Reads — DiskReadBytes

    • Disk Read Operations — DiskReadOps

    • Disk Writes — DiskWriteBytes

    • Disk Write Operations — DiskWriteOps

    • Network In — NetworkIn

    • Network Out — NetworkOut

    • Status Check Failed (Any) — StatusCheckFailed

    • Status Check Failed (Instance) — StatusCheckFailed_Instance

    • Status Check Failed (System) — StatusCheckFailed_System

To view metrics using the CloudWatch console

For more information, see Aggregate Statistics by Auto Scaling Group.

To view CloudWatch metrics using the AWS CLI

To view all metrics for all your Auto Scaling groups, use the following list-metrics command:

aws cloudwatch list-metrics --namespace "AWS/AutoScaling"

To view the metrics for a single Auto Scaling group, specify the AutoScalingGroupName dimension as follows:

aws cloudwatch list-metrics --namespace "AWS/AutoScaling" --dimensions Name=AutoScalingGroupName,Value=my-asg

To view a single metric for all your Auto Scaling groups, specify the name of the metric as follows:

aws cloudwatch list-metrics --namespace "AWS/AutoScaling" --metric-name GroupDesiredCapacity

Create Amazon CloudWatch Alarms

A CloudWatch alarm is an object that monitors a single metric over a specific period. A metric is a variable that you want to monitor, such as average CPU usage of the EC2 instances, or incoming network traffic from many different EC2 instances. The alarm changes its state when the value of the metric breaches a defined range and maintains the change for a specified number of periods.

An alarm has three possible states:

  • OK— The value of the metric remains within the range that you've specified.

  • ALARM— The value of the metric is out of the range that you've specified for a specified time duration.

  • INSUFFICIENT_DATA— The metric is not yet available or there is not enough data available to determine the alarm state.

When the alarm changes to the ALARM state and remains in that state for a number of periods, it invokes one or more actions. The actions can be a message sent to an Auto Scaling group to change the desired capacity of the group.

You configure an alarm by identifying the metrics to monitor. For example, you can configure an alarm to watch over the average CPU usage of the EC2 instances in an Auto Scaling group.

To create a CloudWatch alarm

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

  2. On the navigation pane, choose Alarms.

  3. Choose Create Alarm.

  4. Choose the EC2 Metrics category.

  5. (Optional) You can filter the results. To see the instance metrics, choose Per-Instance Metrics. To see the Auto Scaling group metrics, choose By Auto Scaling Group.

  6. Select a metric, and then choose Next.

  7. Specify a threshold for the alarm and the action to take.

    For more information, see Creating CloudWatch Alarms in the Amazon CloudWatch User Guide.

  8. Choose Create Alarm.