Sub topic 2
Metrics and data points
This chapter covers what a CloudWatch metric is and how data points are stored and retrieved. It assumes you know AWS accounts, regions, and the AWS CLI, and that you have used EC2. Namespaces, dimensions, statistics, and periods get their own chapters. Here you only need the basic model.
What a metric is
A metric is a named, time-ordered set of measurements. CPU utilization of one EC2 instance is a metric. Each measurement in it is a data point. A data point has a timestamp, a value, and a unit such as Percent or Milliseconds.
CloudWatch does not keep a metric as a plain list of every reading. It stores data points by metric identity and time, and it can combine them into statistics when you ask for them. You will see how that works in the chapter on statistics and periods.
Where data points come from
Three sources feed metrics:
- AWS services publish metrics for you. EC2 sends
CPUUtilizationto theAWS/EC2namespace without any setup. - Your own code or scripts publish custom metrics with
put-metric-data. - The CloudWatch agent and metric filters create metrics from hosts and log files.
Resolution and retention
Standard resolution metrics have data points at 1-minute granularity or coarser. High-resolution custom metrics can have data points down to 1 second. Many AWS services report every 5 minutes by default. For EC2, detailed monitoring raises this to 1 minute.
CloudWatch keeps older data at a coarser grain:
| Data point granularity | Retained for |
|---|---|
| Under 60 seconds | 3 hours |
| 1 minute | 15 days |
| 5 minutes | 63 days |
| 1 hour | 455 days (15 months) |
Reading data points
The get-metric-statistics command returns data points for one metric. This call asks for the average and maximum CPU of one instance over an hour, in 5-minute periods.
aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 \
--metric-name CPUUtilization \
--dimensions Name=InstanceId,Value=i-0123456789abcdef0 \
--start-time 2026-11-26T18:00:00Z \
--end-time 2026-11-26T19:00:00Z \
--period 300 \
--statistics Average MaximumThe response contains a Datapoints list. Each entry has a Timestamp, the requested statistic values, and a Unit. The list is not guaranteed to be sorted, so sort by Timestamp before you plot or compare it.
Common errors
- Empty
Datapointslist. The most likely causes are a wrong dimension value, a wrong region, or a time range with no data. The dimension and namespace must match the metric exactly. - Fewer points than expected. A metric that reports every 5 minutes cannot fill 1-minute periods.
- Timestamps in the wrong zone. Use UTC in ISO 8601 form, as in the example.
- Missing permissions. Reading needs
cloudwatch:GetMetricStatistics, and publishing needscloudwatch:PutMetricData.
Exercise
You run get-metric-statistics for an EC2 instance with --period 60, but the instance uses basic monitoring and only reports every 5 minutes. What do you expect, and what can you change?
Show answer
Most 1-minute periods contain no data point, so the response has gaps or few entries. You can use a 300-second period, or enable detailed monitoring on the instance so it reports every minute.