| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
Topics
This set of scenarios shows you how you can use the AWS Management Console,
the mon-get-stats command, or the
GetMetricStatistics API to get a variety of statistics.
Note
Start and end times must be within the last 14 days.
The following table describes the types of monitoring data available for your Amazon EC2 instances.
| Monitoring Type | Description |
|---|---|
|
Basic |
Data is available automatically in 5-minute periods at no charge. |
|
Detailed |
Data is available in 1-minute periods at an additional cost. To get this level of data, you must specifically enable it for the instance. For the instances where you've enabled detailed monitoring, you can also get aggregated data across groups of similar instances. For information about pricing, go to the Amazon CloudWatch product page. |
The following scenario walks you through how to use the AWS Management Console,
the mon-get-stats command, or the
GetMetricStatistics API to determine the maximum CPU utilization of
a specific EC2 instance. For more information about monitoring EC2 instances, see Monitoring Your Instances with CloudWatch in the Amazon Elastic
Compute Cloud User Guide.
Note
Start and end times must be within the last 14 days.
For this example, we assume that you have an EC2 instance ID. You can get an active EC2 instance ID through
the AWS Management Console or with the EC2 ec2-describe-instances CLI command.
To display the average CPU utilization for a specific instance
Open the Amazon CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
If necessary, change the region. From the navigation bar, select the region that meets your needs. For more information, see Regions and Endpoints.

In the navigation pane, click Metrics.

Select EC2: Instance Metrics from the Viewing drop-down list.
The metrics available for individual instances appear in the upper pane.
Select a row that contains CPUUtilization for a specific InstanceId.
A graph showing average CPUUtilization for a single instance
appears in the lower pane.

To get the CPU utilization per EC2 instance
Enter the mon-get-stats command with the following parameters
Prompt>mon-get-stats CPUUtilization --start-time 2011-01-09T23:18:00 --end-time 2011-01-12T23:18:00 --period 360 --namespace "AWS/EC2" --statistics "Maximum" --dimensions "InstanceId=<your-instance-id>" --headersAmazon CloudWatch returns the following (partial listing):
Time Maximum Unit
2011-01-09 23:18:00 0.38 Percent
2011-01-09 23:24:00 0.38 Percent
2011-01-09 23:30:00 0.38 Percent
2011-01-09 23:36:00 0.38 Percent
2011-01-09 23:42:00 0.38 Percent
2011-01-09 23:48:00 0.39 Percent
2011-01-09 23:54:00 0.38 Percent
2011-01-10 00:00:00 0.38 Percent
2011-01-10 00:06:00 0.38 Percent
2011-01-10 00:12:00 0.38 PercentThe returned statistics are six-minute values for the requested two-day time interval. Each value represents the maximum CPU utilization percentage for a single EC2 instance.
To get the CPU utilization per hour for an EC2 instance for a 3-day range
Call GetMetricStatistics with the following parameters:
MetricName = CPUUtilization
Period = 3600
Statistics list includes Maximum
Dimensions
(Name=InstanceId,
Value=")<your-instance-id>"
Namespace = AWS/EC2
StartTime = 2011-01-09T23:18:00
EndTime = 2011-01-12T23:18:00
Aggregate statistics are available for the instances that have detailed
monitoring enabled. Instances that use basic monitoring are not included in the
aggregates. In addition, Amazon CloudWatch does not aggregate data across Regions. Therefore, metrics are
completely separate between Regions. Before you can get statistics aggregated across instances, you must enable
detailed monitoring (at an additional charge), which provides data in 1-minute periods.
This scenario shows you how to use detailed monitoring with either the AWS Management
Console, the GetMetricStatistics API, or the
mon-get-stats command to get the average CPU usage for your EC2
instances. Because no dimension is specified, Amazon CloudWatch returns statistics for
all dimensions in the AWS/EC2 namespace. To get statistics for other metrics,
see Amazon CloudWatch Metrics, Namespaces, and Dimensions Reference.
Important
This technique for retrieving all dimensions across an AWS namespace does not work for custom namespaces that you publish to Amazon CloudWatch. With custom namespaces, you must specify the complete set of dimensions that are associated with any given data point to retrieve statistics that include the data point.
To display average CPU utilization for your Amazon EC2 instances
Open the Amazon CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
If necessary, change the region. From the navigation bar, select the region that meets your needs. For more information, see Regions and Endpoints.

In the navigation pane, click Metrics.

Select EC2: Aggregated Across Instances from the Viewing drop-down list.
The metrics available across all instances appear.
In the upper pane, select the row that contains CPUUtilization.
A graph showing CPUUtilization for your EC2 instances is
displayed in the lower pane.

To get average CPU utilization across your Amazon EC2 instances
Enter the mon-get-stats command with the following parameters:
Prompt>mon-get-stats CPUUtilization --start-time 2011-01-10T23:18:00 --end-time 2011-01-12T23:18:00 --period 360 --namespace "AWS/EC2" --statistics "Average,SampleCount" --headersAmazon CloudWatch returns the following (partial listing):
Time SampleCount Average Unit
2011-01-10 14:18:00 60.0 0.1138 Percent
2011-01-10 15:18:00 60.0 0.1078 Percent
2011-01-10 16:18:00 60.0 0.3322 Percent
2011-01-10 17:18:00 60.0 0.1397 Percent
2011-01-10 18:18:00 60.0 0.1143 Percent
2011-01-10 19:18:00 60.0 0.1082 Percent
2011-01-10 20:18:00 36.0 0.1367 PercentTo get average CPU utilization for your Amazon EC2 instances
Call GetMetricStatistics with the following parameters:
MetricName = CPUUtilization
Statistics list includes Average
Namespace = AWS/EC2
StartTime = 2011-01-10T23:18:00
EndTime = 2011-01-12T23:18:00
Period = 360
The returned statistics are six-minute values for the two-day interval.
This scenario shows you how to use the AWS Management Console, the mon-get-stats command,
or the GetMetricStatistics API with the DiskWriteBytes metric to
retrieve the total bytes written to disk for one Auto Scaling group. The total is computed
for one-minute periods for a 24-hour interval across all EC2 instances in the specified
AutoScalingGroupName.
Note
Start and end times must be within the last 14 days.
We assume for this example that an EC2 application is running and has an Auto Scaling group named test-group-1.
To display total DiskWriteBytes for an Auto-Scaled EC2 application
Open the Amazon CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
If necessary, change the region. From the navigation bar, select the region that meets your needs. For more information, see Regions and Endpoints.

In the navigation pane, click Metrics.

Select EC2: Aggregated by Auto Scaling Group from the Viewing drop-down list.
The metrics available for Auto Scaling groups appear in the Metrics pane.
Select the row that contains DiskWriteBytes.
A graph showing DiskWriteBytes for all EC2 instances appears in the Metrics pane.

To get total DiskWriteBytes for an Auto-Scaled EC2 Application
Enter the mon-get-stats command with the following parameters.
Prompt>mon-get-stats DiskWriteBytes --start-time 2011-01-10T23:18:00 --end-time 2011-01-11T23:18:00 --period 60 --namespace AWS/EC2 --statistics "Sum,SampleCount" --dimensions "AutoScalingGroupName=test-group-1" --headersAmazon CloudWatch returns the following (partial listing):
Time SampleCount Sum Unit
2011-01-10 15:52:00 1.0 196608.0 Bytes
2011-01-10 15:53:00 1.0 180224.0 Bytes
2011-01-10 15:54:00 1.0 200704.0 Bytes
2011-01-10 15:55:00 1.0 200704.0 Bytes
2011-01-10 15:56:00 1.0 200704.0 Bytes
2011-01-10 15:57:00 1.0 180224.0 Bytes
2011-01-10 15:58:00 1.0 196608.0 Bytes
2011-01-10 15:59:00 1.0 372736.0 Bytes
2011-01-10 16:00:00 1.0 258048.0 BytesTo get total DiskWriteBytes for an Auto-Scaled EC2 Application
Call GetMetricStatistics with the following parameters:
MetricName = DiskWriteBytes
Period = 60
Statistics list includes Sum
Unit = Bytes
Dimensions
(Name=AutoScalingGroupName,
Value=test-group-1)
Namespace = AWS/EC2
StartTime = 2011-01-10T23:18:00
EndTime = 2011-01-11T23:18:00
The statistics returned are one-minute totals for bytes written for the entire Auto Scaling group over the 24-hour interval.
This scenario shows you how to use the AWS Management Console, the mon-get-stats command,
or the GetMetricStatistics API to determine average CPU utilization for all
instances that match a given image ID. The average is over 60-second time intervals for a one-day period.
Note
Start and end times must be within the last 14 days.
In this scenario the EC2 instances are running an image ID of ami-c5e40dac.
To display the average CPU utilization for an image ID
Open the Amazon CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
If necessary, change the region. From the navigation bar, select the region that meets your needs. For more information, see Regions and Endpoints.

In the navigation pane, click Metrics.

Select EC2: Aggregated by Image (AMI) Id from the Viewing drop-down list.
The metrics available for image IDs appear in the Metrics pane.
Select a row that contains CPUUtilization and an image ID.
A graph showing average CPUUtilization for all EC2 instances based on the ami-c5e40dac image ID appears in the Metrics pane.

To get the average CPU utilization for an image ID
Enter the mon-get-stats command as in the following example.
Prompt>mon-get-stats CPUUtilization --start-time 2011-01-10T00:00:00 --end-time 2011-01-11T00:00:00 --period 60 --statistics "Average" --namespace "AWS/EC2" --dimensions "ImageId=ami-c5e40dac" --headersAmazon CloudWatch returns the following:
Time Average Unit
2011-01-10 22:42:00 0.38 Percent
2011-01-10 22:48:00 0.39 Percent
2011-01-10 22:54:00 0.38 Percent
2011-01-10 23:00:00 0.38 Percent
2011-01-10 23:06:00 0.38 Percent
2011-01-10 23:12:00 0.38 PercentThe operation returns statistics that are one-minute values for the one-day interval. Each value represents an average CPU utilization percentage for EC2 instances running the specified machine image.
To get the average CPU utilization for an image ID
Call GetMetricStatistics with the following parameters:
MetricName = CPUUtilization
Period = 60
Statistics list includes Average
Dimensions (Name= ImageId,
Value= ami-c5e40dac)
Namespace = AWS/EC2
StartTime = 2011-01-10T00:00:00
EndTime = 2011-01-11T00:00:00