Configure monitoring for Auto Scaling instances
Amazon EC2 collects and processes raw data from instances into readable, near real-time metrics that describe the CPU and other usage data for your Auto Scaling group. You can configure the interval for monitoring these metrics by choosing one-minute or five-minute granularity.
Instance monitoring is enabled whenever an instance is launched, using either basic
monitoring (five-minute granularity) or detailed monitoring (one-minute granularity).
For detailed monitoring, additional charges apply. For more information, see Amazon CloudWatch pricing
Before creating an Auto Scaling group, you should create a launch template or launch configuration that permits the type of monitoring that is appropriate to your application. If you add a scaling policy to your group, we strongly recommend that you use detailed monitoring to get metric data for EC2 instances at a one-minute granularity, because that achieves a faster response to changes in load.
Contents
Enable detailed monitoring (console)
By default, basic monitoring is enabled when you use the Amazon Web Services Management Console to create a launch template or launch configuration.
To enable detailed monitoring in a launch template
When you create the launch template using the Amazon Web Services Management Console, in the Advanced details section, for Detailed CloudWatch monitoring, choose Enable. Otherwise, basic monitoring is enabled. For more information, see Create a launch template using advanced settings.
To enable detailed monitoring in a launch configuration
When you create the launch configuration using the Amazon Web Services Management Console, in the Additional configuration section, select Enable EC2 instance detailed monitoring within CloudWatch. Otherwise, basic monitoring is enabled. For more information, see Create a launch configuration.
Enable detailed monitoring (Amazon CLI)
By default, basic monitoring is enabled when you create a launch template using the Amazon CLI. Detailed monitoring is enabled by default when you create a launch configuration using the Amazon CLI.
To enable detailed monitoring in a launch template
For launch templates, use the create-launch-template command and pass a JSON file that contains
the information for creating the launch template. Set the monitoring attribute
to "Monitoring":{"Enabled":true}
to enable detailed monitoring or
"Monitoring":{"Enabled":false}
to enable basic monitoring.
To enable detailed monitoring in a launch configuration
For launch configurations, 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
Switch between basic and detailed monitoring
To change the type of monitoring enabled on new EC2 instances, update the launch template or update the Auto Scaling group to use a new launch template or launch configuration. Existing instances continue to use the previously enabled monitoring type. To update all instances, terminate them so that they are replaced by your Auto Scaling group or update instances individually using monitor-instances and unmonitor-instances.
Note
With the instance refresh and maximum instance lifetime features, you can also replace all instances in the Auto Scaling group to launch new instances that use the new settings. For more information, see Replace the instances in your Auto Scaling group.
When you switch between basic and detailed monitoring:
If you have CloudWatch alarms associated with the step scaling policies or simple scaling policies for your Auto Scaling group, use the put-metric-alarm command to update each alarm. Make each period match 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 period, they continue to check for statistics every minute. They might find no data available for as many as four out of every five periods.
Collect additional metrics using the CloudWatch agent
To collect operating system-level metrics like available and used memory, you must install the CloudWatch agent. Additional fees may apply. You can use the CloudWatch agent to collect both system metrics and log files from Amazon EC2 instances. For more information, see Metrics collected by the CloudWatch agent in the Amazon CloudWatch User Guide.