Sub topic 1
What CloudWatch Does: Metrics, Logs, Alarms, and Dashboards
Prerequisites
This chapter assumes you understand AWS accounts, regions, IAM permissions, and basic EC2 concepts. You should also be comfortable running AWS CLI commands and know the difference between a log and a metric.
CloudWatch’s Main Signals
Amazon CloudWatch collects operational data from AWS resources and applications. Metrics are numeric measurements, such as CPU percentage or request latency. Logs are records of events, such as application errors. Alarms evaluate metrics against conditions and can notify or trigger actions. Dashboards display related metrics in one view.
Metrics and Data Points
A metric is a named stream of numeric data. Each measurement is a data point with a timestamp and value. For example, an EC2 instance can publish CPUUtilization at 72 percent at a specific time.
CloudWatch stores metric data by region. A metric's meaning depends on how it was collected and how you query it. A five-minute average can hide a short spike that a one-minute average would show.
Namespaces and Dimensions
A namespace groups related metrics. AWS services use namespaces such as AWS/EC2; your application can use a custom namespace such as MyApp.
A dimension is a name-value pair that identifies a metric variation. Service=checkout separates checkout measurements from other services. The namespace, metric name, and complete set of dimensions identify one metric.
Statistics, Periods, and Units
A statistic summarizes values within a period. Common statistics include Average, Maximum, Minimum, and Sum. The period is the length of each interval, expressed in seconds in many CLI commands. Units such as Percent, Count, and Milliseconds document how to interpret values.
Publishing Custom Metrics
You can publish application measurements with the AWS CLI:
aws cloudwatch put-metric-data \
--namespace MyApp \
--metric-name PageLoadTime \
--dimensions Service=checkout \
--unit Milliseconds \
--value 230You can then retrieve statistics for an AWS metric:
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 MaximumExercise
Why would Service=checkout matter when publishing a custom metric?
Show answer
It identifies the service that produced the data, allowing checkout measurements to be queried separately from other services.