โšก Onwuachi Control Plane

CloudWatch Metrics, Alarms, and SNS Notifications

Overview

CloudWatch is AWS’s managed monitoring platform โ€” equivalent to a hosted Prometheus + Alertmanager stack. It collects metrics from AWS services and custom sources, evaluates thresholds via alarms, and routes notifications through SNS to email, Lambda, or other targets.

Why It Matters

Without CloudWatch alarms, AWS infrastructure fails silently. An ASG at zero capacity, an EC2 instance with 100% CPU, an ALB returning 5xx errors โ€” none of these page anyone unless an alarm is wired up. CloudWatch is the difference between reactive firefighting and proactive operations.

Where It Fits

DOP-C02 Domain 4 โ€” Monitoring and Logging

AWS Service (EC2, ASG, ALB) | v CloudWatch Metric (time-series datapoint) | v CloudWatch Alarm (threshold evaluation) | v Alarm Action (SNS โ†’ email / Lambda / ASG scaling policy)


The Big Picture

Your platform today AWS Equivalent


Prometheus metric โ†’ CloudWatch Metric PromQL threshold rule โ†’ CloudWatch Alarm Alertmanager โ†’ Alarm Action (SNS) Grafana dashboard โ†’ CloudWatch Dashboard


Core Concepts

Two metric tiers:

Native AWS Metrics (free) โ€” every AWS service publishes automatically:

Custom Metrics (~$0.30/metric/month) โ€” your app or CloudWatch Agent publishes via PutMetricData:

Exam trap: EC2 native metrics do NOT include memory or disk โ€” those require the CloudWatch Agent.

Alarm states:

OK โ€” metric within threshold ALARM โ€” metric breached threshold INSUFFICIENT_DATA โ€” not enough datapoints yet (new resources)

treat-missing-data โ€” critical for exam:

breaching โ€” missing data = bad (capacity/availability alarms) notBreaching โ€” missing data = ok (error rate alarms โ€” no traffic = no errors) ignore โ€” keep current state missing โ€” INSUFFICIENT_DATA (default)

Alarm types:

Alarm actions:


Real-World Example

Live lab in devopslab, account 046685909731:

Created alarm dop-lab-asg-low-capacity on GroupInServiceInstances for ASG dop-lab-asg:

SNS topic dop-lab-alerts created, onwuabus@gmail.com subscribed and confirmed. Alarm wired to SNS via --alarm-actions and --ok-actions.

Key observation: fresh ASGs can take 5-10 minutes to start publishing group metrics to CloudWatch. INSUFFICIENT_DATA or no datapoints on a new ASG is expected โ€” not a misconfiguration.

Alarm creation runbook:

aws cloudwatch put-metric-alarm \
  --alarm-name <name> \
  --metric-name GroupInServiceInstances \
  --namespace AWS/AutoScaling \
  --dimensions Name=AutoScalingGroupName,Value=<asg-name> \
  --statistic Average \
  --period 60 \
  --threshold 1 \
  --comparison-operator LessThanThreshold \
  --evaluation-periods 1 \
  --treat-missing-data breaching \
  --alarm-actions <sns-arn> \
  --ok-actions <sns-arn>

# Verify state
aws cloudwatch describe-alarms \
  --alarm-names <name> \
  --query "MetricAlarms[0].{State:StateValue,Reason:StateReason}" \
  --output table

Engineering Analogy

CloudWatch alarms are Prometheus alerting rules โ€” a threshold evaluated against a time-series metric that fires a notification when breached. The difference: CloudWatch is pull-free (AWS pushes metrics automatically), whereas Prometheus requires a scrape target. SNS is Alertmanager โ€” routes the alert to the right destination.


Best Practices


Common Mistakes


Pro Tip

aws cloudwatch list-metrics --namespace AWS/AutoScaling shows what metrics are actually being published for your ASG. If GroupInServiceInstances doesn’t appear, the ASG hasn’t emitted a datapoint yet โ€” wait 5-10 minutes before assuming a misconfiguration.


Key Takeaways


Related Articles


References

System Context

โ† Back to Kb