1.Metrics, Dimensions, and Statistics
A CloudWatch metric is a time-ordered set of data points — one variable you watch over time, such as an EC2 instance's CPU usage. Each metric is identified by a namespace, a name, and up to thirty dimensions (name/value pairs like `InstanceId=i-0abc`). You never read the raw points directly: you ask for a statistic — Average, Sum, Maximum, a percentile — aggregated over a period you choose.
Key features
- A metric is uniquely defined by a namespace, a name, and zero or more dimensions; every unique dimension combination is treated as a separate metric
- You can assign up to 30 dimensions to a metric, and AWS namespaces follow the `AWS/{service}` convention (`AWS/EC2`, `AWS/Lambda`)
- Standard resolution is one-minute granularity; high resolution is one second, and is only available on custom metrics you publish that way
- A period is the aggregation window: valid values are 1, 5, 10, 30, or any multiple of 60 seconds, defaulting to 60
- Retention is tiered — sub-60-second points for 3 hours, 60-second for 15 days, 5-minute for 63 days, 1-hour for 455 days — with automatic rollup as data ages
- Metrics exist only in their own Region, cannot be deleted, and expire after 15 months with no new data; percentiles need raw, unsummarized points, so publishing a statistic set makes percentile statistics unavailable except in narrow cases
Metric retention and rollup
- Whole: AWS/ApplicationELB · TargetResponseTime · {LoadBalancer=app/api-lb, TargetGroup=tg-api} · p99 over 60s
- AWS/ApplicationELB — Namespace: The container. Metrics in different namespaces never aggregate together.
- TargetResponseTime — Metric name: The variable being measured over time.
- {LoadBalancer=app/api-lb, TargetGroup=tg-api} — Dimensions: Name/value pairs that are part of the identity — a different combination is a different metric.
- p99 over 60s — Statistic + period: How the points are aggregated, and over what window. Chosen at read time, not at publish time.
Signature
metric = namespace + name + dimensions[≤30] · read as statistic over period (1|5|10|30|60n s)
namespace + name + dimensions identify a metric; every dimension combination is its own metric, so keep cardinality bounded. Statistic and period are read-time choices. Retention is tiered with rollup — 1-minute data for 15 days, 5-minute for 63 days, 1-hour for 15 months.