AWS CloudWatch Dashboards and Alarms
Custom dashboards and composite alarms.
AWS CloudWatch: Dashboards and Alarms
CloudWatch is AWS's native monitoring service, providing metrics, logs, alarms, and dashboards for all AWS resources. While third-party tools offer more flexibility, CloudWatch's deep AWS integration and zero-setup metrics collection make it an essential part of any AWS monitoring strategy.
Custom Dashboards
Create dashboards that show the health of your entire application at a glance:
aws cloudwatch put-dashboard --dashboard-name ProductionOverview --dashboard-body '{
"widgets": [
{
"type": "metric",
"properties": {
"metrics": [
["AWS/ApplicationELB", "RequestCount", "LoadBalancer", "app/prod-alb/xxx", {"stat": "Sum", "period": 60}],
["AWS/ApplicationELB", "HTTPCode_Target_5XX_Count", "LoadBalancer", "app/prod-alb/xxx", {"stat": "Sum", "period": 60}]
],
"title": "ALB Request Count & 5xx Errors",
"period": 300,
"view": "timeSeries"
}
},
{
"type": "metric",
"properties": {
"metrics": [
["AWS/RDS", "CPUUtilization", "DBInstanceIdentifier", "prod-db"],
["AWS/RDS", "DatabaseConnections", "DBInstanceIdentifier", "prod-db"]
],
"title": "RDS Performance"
}
}
]
}'Metric Math
Combine metrics with mathematical expressions:
# Error rate percentage
# m1 = 5xx count, m2 = total requests
METRICS(m1/m2*100) AS "Error Rate %"
# Useful expressions:
# ANOMALY_DETECTION_BAND(m1, 2) - automatic anomaly detection
# FILL(m1, 0) - replace missing data points with 0
# RATE(m1) - per-second rate of changeComposite Alarms
Combine multiple alarms to reduce false positives:
# Individual alarms
aws cloudwatch put-metric-alarm \
--alarm-name high-cpu \
--metric-name CPUUtilization \
--namespace AWS/EC2 \
--statistic Average \
--period 300 \
--evaluation-periods 3 \
--threshold 80 \
--comparison-operator GreaterThanThreshold
aws cloudwatch put-metric-alarm \
--alarm-name high-5xx \
--metric-name HTTPCode_Target_5XX_Count \
--namespace AWS/ApplicationELB \
--statistic Sum \
--period 60 \
--evaluation-periods 3 \
--threshold 10 \
--comparison-operator GreaterThanThreshold
# Composite alarm - only fires when BOTH conditions are true
aws cloudwatch put-composite-alarm \
--alarm-name production-degraded \
--alarm-rule 'ALARM("high-cpu") AND ALARM("high-5xx")' \
--alarm-actions arn:aws:sns:us-east-1:xxx:pagerdutyAnomaly Detection
CloudWatch can automatically learn normal patterns and alert on deviations:
aws cloudwatch put-anomaly-detector \
--namespace AWS/ApplicationELB \
--metric-name RequestCount \
--stat Sum \
--dimensions Name=LoadBalancer,Value=app/prod-alb/xxx
aws cloudwatch put-metric-alarm \
--alarm-name request-anomaly \
--metrics '[{"Id":"m1","MetricStat":{"Metric":{"Namespace":"AWS/ApplicationELB","MetricName":"RequestCount"},"Period":300,"Stat":"Sum"}},{"Id":"ad1","Expression":"ANOMALY_DETECTION_BAND(m1, 2)"}]' \
--threshold-metric-id ad1 \
--comparison-operator LessThanLowerOrGreaterThanUpperThresholdEssential Alarms to Configure
| Service | Metric | Threshold |
|---|---|---|
| ALB | 5XX Error Rate | >1% for 5 minutes |
| ALB | Target Response Time | >2s P95 for 5 minutes |
| EC2/ECS | CPU Utilization | >80% for 15 minutes |
| RDS | CPU Utilization | >80% for 10 minutes |
| RDS | FreeStorageSpace | <10GB |
| RDS | DatabaseConnections | >80% of max |
Eazy SaaS Tip: We set up CloudWatch dashboards with a "traffic light" layout: green for healthy, yellow for warning, red for critical. Combined with composite alarms that reduce noise, our clients get actionable alerts — not alarm fatigue.