CloudWatch metrics
CloudWatch metrics, namespaces and dimensions, standard and high resolution, how long data is kept, custom metrics, dashboards, and metric streams to Firehose and third-party tools.
Metrics
Amazon CloudWatch provides metrics for every service in AWS.
- A metric is a variable to monitor:
CPUUtilization,NetworkIn… - Metrics belong to namespaces (
AWS/EC2,AWS/RDS, or a custom one, such asMyApp). - A dimension is an attribute of a metric: instance ID, environment… Up to 30 dimensions per metric.
- Metrics have timestamps.
- CloudWatch dashboards of metrics can be built.
- Custom metrics can be created, for example for RAM (EC2 doesn't publish memory usage by itself).
Resolution and retention:
- AWS services publish standard resolution metrics: one data point per minute (EC2 basic monitoring: every 5 minutes; detailed monitoring: every minute, for a charge).
- Custom metrics can be high resolution, down to 1 second.
- Data is kept for 15 months, and gets coarser with age: 1-minute points for 15 days, 5-minute points for 63 days, 1-hour points for 455 days.
Custom metrics
A custom metric is published with the PutMetricData API (or the CloudWatch agent, which collects RAM, disk space and processes automatically):
aws cloudwatch put-metric-data --namespace "MyApp" \
--metric-name ActiveUsers --dimensions Env=prod --value 42- Use dimensions to split it (by instance, by environment).
- Choose the storage resolution: 60 seconds (standard) or 1 second (high resolution, more cost).
CloudWatch metric streams
Metric streams continually stream CloudWatch metrics to a chosen destination, with near-real-time delivery and low latency:
- Amazon Data Firehose (and then its destinations: S3, Redshift, OpenSearch…);
- third-party service providers: Datadog, Dynatrace, New Relic, Splunk, Sumo Logic…
Metrics can be filtered to stream only a subset of them.
Real-world examples
- An online shop publishes
OrdersPerMinuteas a custom metric and puts it on a dashboard next to EC2 CPU and ALB latency. - A company that uses Datadog streams all CloudWatch metrics to it with a metric stream, instead of polling the CloudWatch API.
Exam tips
- "Monitor RAM (memory) or disk space of EC2" → custom metric, usually through the CloudWatch agent.
- "Metrics every second" → high-resolution custom metrics. "EC2 metrics every minute" → detailed monitoring.
- "Send CloudWatch metrics to a third-party tool or S3 in near real time" → metric streams.
Common traps
- "EC2 reports memory usage by default." It doesn't; CPU, network, disk I/O and status checks are built in, RAM is a custom metric.
- "Metrics are kept forever." At most 15 months.
Hands-on lab: publish a custom metric
Goal: send your own metric to CloudWatch and graph it.
Costs money
A custom metric costs about $0.30 a month, charged by the hour, and API calls cost $0.01 per 1,000, so this lab costs less than a cent if you finish within a day. Any Region works.
Publish data points
In CloudShell, run the put-metric-data command above three times with different values (42, 55, 37), a minute apart.
Graph it
Open CloudWatch → Metrics → All metrics → Custom namespaces → MyApp → Env, tick ActiveUsers, and set the period to 1 minute.
Expected result: a graph with your three points.
Clean up: nothing to delete; a metric with no new data stops being billed and expires after 15 months.
AWS documentation
Monitoring & Governance
Monitoring, auditing and compliance on AWS, the difference between CloudWatch, CloudTrail and AWS Config, a load balancer example, and the map of this group.
CloudWatch Logs
CloudWatch Logs groups and streams, retention, encryption and log classes, log sources, Logs Insights, exporting to S3, subscriptions, cross-account aggregation, and the CloudWatch agent.