Sub topic 2
Metrics and data points
This chapter covers the working model of a CloudWatch metric: what a data point is, how it is stored, how long it is kept, and how timing and resolution affect what you see. It assumes you know AWS accounts, regions, and IAM permissions, can run AWS CLI commands, and understand in general terms what a metric is. Namespaces, dimensions, statistics, and periods get their own chapters. This chapter uses them only as far as needed.
What a metric is
A metric is a named, time-ordered set of numeric data points. A data point is one observation: a timestamp, a value, and a unit. CPU utilization of one EC2 instance is a metric. Each reading of that CPU value is a data point on it.
CloudWatch stores metrics, not individual events. You send a measurement, and CloudWatch files it under the metric it belongs to. You can then ask for summaries of that metric over time. You can't ask for "the 14th reading" as a separate record. You ask for a statistic over a time window.
A metric exists in a specific region. A metric in us-east-1 is not visible in eu-west-1. A metric is also tied to the account that owns it, unless you set up cross-account sharing, which a later chapter covers.
Anatomy of a data point
Every data point has these parts:
| Part | Meaning | Notes |
|---|---|---|
| Timestamp | When the observation applies | Stored in UTC. Defaults to the time CloudWatch receives it if you omit it. |
| Value | The measurement | A double-precision number. Very large and very small values are clipped. |
| Unit | What the number means | Optional, for example `Percent`, `Bytes`, `Milliseconds`, or `Count`. |
You can also send a pre-aggregated data point. Instead of one value, you send a statistic set: a sample count, a sum, a minimum, and a maximum. CloudWatch then treats that one data point as a summary of many observations. This helps when your application records thousands of measurements per second and you don't want to make thousands of API calls.
Here is the call from this tutorial's examples. It publishes one data point for a metric called PageLoadTime:
aws cloudwatch put-metric-data \
--namespace MyApp \
--metric-name PageLoadTime \
--dimensions Service=checkout \
--unit Milliseconds \
--value 230No timestamp is given, so CloudWatch uses the receive time. The data point has the value 230 and the unit Milliseconds. It belongs to the metric identified by the name PageLoadTime, the namespace MyApp, and the dimension Service=checkout.
Where metrics come from
Metrics reach CloudWatch in three ways:
- AWS services publish them automatically. EC2, EBS, Lambda, RDS, and most other services send metrics to namespaces that start with
AWS/. You don't configure this, and the metrics themselves cost nothing to store. - You publish custom metrics yourself with
put-metric-data, an SDK, or the CloudWatch agent. - CloudWatch derives metrics from other data, for example from log events through metric filters.
Basic monitoring for EC2 reports at 5-minute intervals. Detailed monitoring reports at 1-minute intervals and carries a charge. This difference matters later, because an alarm that evaluates 1-minute periods against a 5-minute metric sees mostly gaps.
Resolution: standard and high
Resolution is how finely you can slice a metric in time.
- Standard resolution stores data at 1-minute granularity.
- High resolution stores data at 1-second granularity. You request it by setting the storage resolution to 1 when you publish.
Most AWS service metrics are standard resolution. High resolution is available for custom metrics. It is useful for bursty workloads where a one-minute average hides a ten-second spike, but it costs more and produces more data to query.
Retention and automatic rollup
CloudWatch keeps metric data for 15 months. It does not keep the full-resolution data for that long. As data ages, CloudWatch rolls it up into coarser periods:
| Age of data | Finest period available |
|---|---|
| Up to 3 hours | 1 second (high-resolution metrics only) |
| Up to 15 days | 1 minute |
| Up to 63 days | 5 minutes |
| Up to 15 months | 1 hour |
Two consequences follow from this table.
First, you can't retrieve 1-minute data for something that happened last month. If you request a period finer than the data's age allows, you get nothing useful back, or you must request a coarser period. Second, short spikes disappear from older data. A 90-second burst to 100% CPU is visible at 1-minute resolution this week. In a 1-hour rollup next year it is averaged into the rest of the hour.
If you need fine-grained history, export it before it ages out, or record the aggregates you care about, such as a maximum, as their own metrics.
You also can't delete a metric. Metrics expire when they stop receiving data and their last data point ages past the retention window. Publishing to a wrong name leaves a stray metric until it expires.
Timestamps and what CloudWatch accepts
CloudWatch accepts data points with timestamps up to 2 weeks in the past and up to 2 hours in the future. Anything outside that range is rejected. This is the first place to look when put-metric-data returns an error for a batch job that backfills old data.
Data points do not appear instantly. Metrics from AWS services arrive with a delay. A just-published custom metric is usually queryable within a minute or two, but a short lag is normal. Recent periods can also look incomplete because late data points are still arriving. Alarms and dashboards that evaluate the most recent period can briefly see partial data. The --treat-missing-data setting on alarms exists partly for this reason.
Reading a metric back
You query a metric by naming it fully (namespace, metric name, dimensions) and asking for statistics over a time range and period. This call retrieves the average and maximum CPU of one instance in 5-minute buckets over one hour:
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 MaximumNotice what the response is. CloudWatch does not return the raw data points. It groups the points inside each 300-second window and returns the statistics you asked for. One hour at a 300-second period gives at most 12 returned entries. The entries come back unordered, so sort by Timestamp if you need a sequence.
A few details trip people up:
- Dimensions must match exactly. Querying
InstanceIdalone will not return a metric that was published withInstanceIdandAutoScalingGroupNametogether. Each distinct combination is a separate metric. - A metric with no data in the range returns an empty
Datapointslist, not an error. A typo in the metric name looks the same as a quiet metric. get-metric-statisticsis limited to 1,440 data points per call. A longer range with a small period must be split into several calls, or you can useget-metric-data, which supports larger queries and metric math.
To find out which metrics exist, list them:
aws cloudwatch list-metrics --namespace AWS/EC2 --metric-name CPUUtilizationlist-metrics shows only metrics that have received data in roughly the last two weeks. A metric you published once last month will not appear, even though its old data points may still be queryable if you know its exact identity.
The life of a data point
The diagram below traces a data point from producer to query.
Common errors
- Empty results for a metric that surely exists. Check the region, the namespace spelling, and that the dimensions match exactly. Also confirm the time range falls inside the retention window for the period you chose.
- Rejected data points. A timestamp more than 2 weeks old or 2 hours ahead is refused. Check clock skew on the producing host.
- Flat or gappy graphs for EC2. Basic monitoring emits every 5 minutes. A 1-minute period shows a point only every fifth minute.
- A spike that vanished from a month-old graph. Rollup averaged it away. Use the Maximum statistic, and remember that old data is only available at coarse periods.
- Treating the metric as a log. A metric holds numbers only. If you need the text of an error, send it to logs, which later chapters cover.
Exercise
A batch job tries to send a data point stamped 20 days ago, and a separate dashboard widget requests 1-minute data for an event from 30 days ago. What happens in each case, and why?
Show answer
The put is rejected, because CloudWatch only accepts timestamps from up to 2 weeks in the past to 2 hours in the future. The widget cannot get 1-minute data for a 30-day-old event, because 1-minute data is kept only 15 days. After that the data exists only at 5-minute resolution (up to 63 days), so the widget must use a period of 300 seconds or more.
Exercise
You publish a custom metric with --dimensions Service=checkout, then run get-metric-statistics for the same namespace and metric name with no dimensions. You get an empty result. Why?
Show answer
Dimensions are part of a metric's identity. The metric published with Service=checkout is a different metric from the same name with no dimensions. The query must supply the same dimension name and value. Publishing without dimensions would create a separate metric.