Metrics Deep Dive: Metric Streams, Grafana, Prometheus and Analytics
Overview
Task 4.1 of DOP-C02 asks you to audit, monitor and analyse logs and metrics to detect issues. Knowing how CloudWatch organises metrics, how to publish your own, and how to export them to other tools lets you build the right observability platform for each team.
Think of metrics as a city's sensor network. Namespaces are districts, dimensions are street addresses and resolution is how often a sensor reports. Metric streams, Grafana and Prometheus are the different control rooms that can watch the same sensors.
You must be able to pick between native CloudWatch features and open-source-compatible managed services, and explain cost and cardinality trade-offs.
Key Concepts
- A metric is identified by namespace + metric name + dimensions; every unique dimension combination is a separate metric and a cost driver.
- Standard resolution is 1 minute; high-resolution custom metrics go down to 1 second (alarms down to 10 s).
PutMetricData, the CloudWatch agent, EMF and StatsD/collectd publish custom metrics.- Metric math combines metrics (rates, SEARCH, ANOMALY_DETECTION_BAND, IF) for alarms and dashboards.
- Metric Streams continuously deliver metrics through Firehose to S3 or third-party tools with low latency, in OpenTelemetry or JSON format.
- Amazon Managed Service for Prometheus is a Prometheus-compatible store (PromQL, remote write) for container metrics from EKS/ECS.
- Amazon Managed Grafana provides dashboards over CloudWatch, Prometheus, X-Ray, OpenSearch and Athena with SSO.
- Athena and QuickSight analyse exported metrics and logs from S3 for reporting.
Detailed Notes
Choosing the metrics platform
| Need | Choice |
|---|---|
| AWS service metrics and alarms | CloudWatch |
| Cross-service dashboards for many data sources | Managed Grafana |
| Kubernetes and container metrics, PromQL | Managed Prometheus (with ADOT collector) |
| Stream all metrics to a SIEM or partner | Metric Streams to Firehose |
| Long-term analytics and BI | Metric Streams or logs to S3, Athena, QuickSight |
| Business KPIs from logs | EMF or metric filters |
Publishing custom metrics
aws cloudwatch put-metric-data --namespace Shop/Checkout --metric-name OrdersPlaced \
--dimensions Env=prod,Region=us-east-1 --value 12 --unit Count --storage-resolution 1
{
"_aws": { "Timestamp": 1735700000000,
"CloudWatchMetrics": [{ "Namespace": "Shop/Checkout", "Dimensions": [["Env"]],
"Metrics": [{ "Name": "Latency", "Unit": "Milliseconds" }] }] },
"Env": "prod", "Latency": 182
}
Avoid high-cardinality dimensions (user ID, request ID): each combination is a billable metric. Put those values in logs or X-Ray annotations instead.
Metric math and anomaly detection
m1/m2*100computes an error percentage;SEARCH('{AWS/EC2,InstanceId} MetricName="CPUUtilization"', 'Average', 300)aggregates dynamically across fleets.- Anomaly detection trains on up to two weeks of data and builds a band that adapts to daily and weekly seasonality; alarm when the metric leaves the band.
- Metrics are retained 15 months with resolution rolling up (1 s for 3 hours, 1 min for 15 days, 5 min for 63 days, 1 hour for 455 days).
Metric Streams
aws cloudwatch put-metric-stream --name all-metrics --firehose-arn arn:aws:firehose:us-east-1:111122223333:deliverystream/metrics \
--role-arn arn:aws:iam::111122223333:role/MetricStreamRole --output-format opentelemetry1.0 \
--include-filters Namespace=AWS/EC2 Namespace=AWS/RDS
Use include or exclude filters, and optionally statistics additional to the defaults. Streams are the right answer for "near-real-time export of CloudWatch metrics to a third-party tool or data lake".
Containers: Prometheus and Container Insights
- Container Insights collects cluster, node, pod and task metrics and logs (enhanced observability for EKS adds more detail) with the CloudWatch agent or ADOT.
- Managed Prometheus ingests via remote write from an ADOT or Prometheus server and scales without managing storage; query with PromQL; alert with the Prometheus alert manager.
- Managed Grafana connects to both and supports SAML or IAM Identity Center sign-in.
Analysing logs and metrics
- Query CloudWatch Logs with Insights for ad hoc work; export to S3 (Parquet via Firehose) for Athena SQL across months of data.
- Use QuickSight for executive dashboards fed by Athena, and Cost and Usage Reports for FinOps metrics.
- Encrypt log groups with KMS, set retention, and use lifecycle rules on archived buckets.
Common troubleshooting
| Symptom | Likely cause |
|---|---|
| Metric missing | Wrong namespace/dimensions, agent not running or no PutMetricData permission |
| Alarm in INSUFFICIENT_DATA | Sparse metric with default missing-data handling |
| Surprising bill | High-cardinality custom metrics or detailed logging with no retention |
| Memory and disk metrics missing for EC2 | They need the CloudWatch agent; they are not default metrics |
Real World Example
Scenario: a platform team runs 40 EKS clusters and a security team needs every CloudWatch metric in a third-party tool. The platform team uses ADOT collectors with remote write into Managed Prometheus and a shared Managed Grafana workspace secured by IAM Identity Center groups.
A CloudWatch metric stream with namespace filters sends AWS service metrics through Firehose to the partner tool and, in Parquet, to S3 for Athena and QuickSight capacity reports.
Architecture Diagram
Sources feed CloudWatch, Prometheus and streams, which feed dashboards and analytics.
- 1Applications and services publish metrics (native, agent, EMF, remote write).
- 2CloudWatch stores and alarms on them, with metric math and anomaly detection.
- 3A metric stream exports them in near real time through Firehose.
- 4S3 holds the long-term data for Athena queries.
- 5Grafana and QuickSight present dashboards to engineers and executives.
Best Practices
- ✓Keep dimension cardinality low; put IDs in logs or traces.
- ✓Use EMF for metrics from Lambda and containers to avoid API throttling.
- ✓Use anomaly detection for seasonal signals and static thresholds for hard limits.
- ✓Choose Managed Prometheus and Grafana for Kubernetes-native teams, CloudWatch for AWS-native alarms.
- ✓Export with Metric Streams instead of polling GetMetricData for large-scale needs.
Common Interview Questions
Exam Tips
DOP-C02 focus
- "Near real-time export of all metrics to S3 or partner" = CloudWatch Metric Streams + Firehose.
- "PromQL for Kubernetes" = Managed Service for Prometheus.
- "Memory metrics from EC2" = CloudWatch agent.
- "Custom metric under 1 minute" = high-resolution (storage-resolution 1).
Finished this lesson?
0 of 44 lessons done · 0% of the course

