Aggregate statistics across resources - Amazon CloudWatch
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Aggregate statistics across resources

You can aggregate the metrics for Amazon resources across multiple resources. Metrics are completely separate between Regions, but you can use metric math to aggregate similar metrics across Regions. For more information, see Using math expressions with CloudWatch metrics.

For example, you can aggregate statistics for your EC2 instances that have detailed monitoring enabled. Instances that use basic monitoring aren't included. Therefore, you must enable detailed monitoring (at an additional charge), which provides data in 1-minute periods. For more information, see Enable or Disable Detailed Monitoring for Your Instances in the Amazon EC2 User Guide.

This example shows you how to get the average CPU usage for your EC2 instances. Because no dimension is specified, CloudWatch returns statistics for all dimensions in the AWS/EC2 namespace. To get statistics for other metrics, see Amazon services that publish CloudWatch metrics.

Important

This technique for retrieving all dimensions across an Amazon namespace doesn't work for custom namespaces that you publish to 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 EC2 instances
  1. Open the CloudWatch console at https://console.amazonaws.cn/cloudwatch/.

  2. In the navigation pane, choose Metrics.

  3. Choose the EC2 namespace and choose Across All Instances.

  4. Select the row that contains CPUUtilization, which displays a graph for the metric for all your EC2 instances. To change the name of the graph, choose the pencil icon. To change the time range, select one of the predefined values or choose custom.

    Metrics aggregated across your EC2 instances
  5. To change the statistic, choose the Graphed metrics tab. Choose the column heading or an individual value and then choose one of the statistics or predefined percentiles, or specify a custom percentile (for example, p95.45).

  6. To change the period, choose the Graphed metrics tab. Choose the column heading or an individual value and then choose a different value.

To get average CPU utilization across your EC2 instances using the Amazon CLI

Use the get-metric-statistics command as follows:

aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name CPUUtilization --statistics "Average" "SampleCount" \ --start-time 2016-10-11T23:18:00 --end-time 2016-10-12T23:18:00 --period 3600

The following is example output:

{ "Datapoints": [ { "SampleCount": 238.0, "Timestamp": "2016-10-12T07:18:00Z", "Average": 0.038235294117647062, "Unit": "Percent" }, { "SampleCount": 240.0, "Timestamp": "2016-10-12T09:18:00Z", "Average": 0.16670833333333332, "Unit": "Percent" }, { "SampleCount": 238.0, "Timestamp": "2016-10-11T23:18:00Z", "Average": 0.041596638655462197, "Unit": "Percent" }, ... ], "Label": "CPUUtilization" }