CloudWatch Alarms and Composite Alarms
Set threshold-based alarms to trigger Auto Scaling or SNS notifications, and combine multiple alarms into a composite alarm to reduce alert noise.
CloudWatch Alarms and Composite Alarms is a free AWS Solutions Architect lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS Solutions Architect learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What Is a CloudWatch Alarm?
A CloudWatch alarm monitors a single metric or the result of a metric math expression over a time period you specify. When the metric crosses a threshold you define, the alarm changes state and can automatically trigger an action such as sending an SNS notification, scaling an Auto Scaling group, stopping an EC2 instance, or executing a Systems Manager OpsItem. Alarms are the primary mechanism for automated operational response in AWS.
Alarm States
A CloudWatch alarm is always in one of three states: OK — the metric is within the defined threshold; ALARM — the metric has breached the threshold for the required number of evaluation periods; INSUFFICIENT_DATA — the alarm has just been created, the metric is not available, or not enough data has been collected yet. Transitions between states trigger actions configured for that state change — you can have different SNS topics for OK, ALARM, and INSUFFICIENT_DATA states.
# View all alarms and their current state
aws cloudwatch describe-alarms \
--query 'MetricAlarms[].{Name:AlarmName,State:StateValue,Metric:MetricName}' \
--output table
# List only alarms currently in ALARM state
aws cloudwatch describe-alarms \
--state-value ALARM \
--query 'MetricAlarms[].AlarmName'Creating a CloudWatch Alarm
When creating an alarm you specify: the metric and namespace, the statistic (Average, Sum, Maximum, etc.), the period (how often the metric is evaluated in seconds), the evaluation periods (how many consecutive periods must breach the threshold), the threshold value, and the comparison operator. The alarm triggers when the metric breaches the threshold for the specified number of consecutive evaluation periods.
# Create an alarm: trigger when CPU > 70% for 2 consecutive 5-min periods
aws cloudwatch put-metric-alarm \
--alarm-name HighCPUAlarm \
--alarm-description 'Trigger when EC2 CPU exceeds 70%' \
--metric-name CPUUtilization \
--namespace AWS/EC2 \
--dimensions Name=InstanceId,Value=i-0123456789abcdef0 \
--statistic Average \
--period 300 \
--evaluation-periods 2 \
--threshold 70 \
--comparison-operator GreaterThanThreshold \
--alarm-actions arn:aws:sns:us-east-1:111122223333:AlertTeamAlarm Actions: SNS, Auto Scaling, EC2
Alarm actions can target several destinations: Amazon SNS topics (to send email, SMS, or trigger Lambda), Auto Scaling policies (to scale in or scale out an ASG), and EC2 actions (to stop, terminate, reboot, or recover an EC2 instance). For each state (OK, ALARM, INSUFFICIENT_DATA) you can specify a different set of actions — for example, notify the team on ALARM, notify on recovery with OK, and alert on INSUFFICIENT_DATA to catch monitoring gaps.
# Alarm that stops an idle EC2 instance when CPU < 1% for 30 min
aws cloudwatch put-metric-alarm \
--alarm-name LowCPUStopInstance \
--metric-name CPUUtilization \
--namespace AWS/EC2 \
--dimensions Name=InstanceId,Value=i-0123456789abcdef0 \
--statistic Average \
--period 300 \
--evaluation-periods 6 \
--threshold 1 \
--comparison-operator LessThanThreshold \
--alarm-actions arn:aws:swf:us-east-1:111122223333:action/actions/AWS_EC2.InstanceId.Stop/1.0Missing Data Treatment
When CloudWatch evaluates an alarm and some data points are missing, you must decide how to treat them. Options are: notBreaching (treat missing data as within threshold — alarm stays OK if other data is OK), breaching (treat missing as exceeding threshold — alarm moves to ALARM), ignore (the alarm state doesn't change), and missing (alarm moves to INSUFFICIENT_DATA). Choosing the wrong option leads to false positives or silent failures — a key SAA-C03 exam nuance.
# Set missing data treatment on an alarm
aws cloudwatch put-metric-alarm \
--alarm-name WebsiteLatencyAlarm \
--metric-name TargetResponseTime \
--namespace AWS/ApplicationELB \
--statistic Average \
--period 60 \
--evaluation-periods 3 \
--threshold 2.0 \
--comparison-operator GreaterThanThreshold \
--treat-missing-data breaching \
--alarm-actions arn:aws:sns:us-east-1:111122223333:OpsAlarm Resolution and Evaluation Periods
The alarm resolution is the product of period × evaluation-periods. For example, a period of 60 seconds with 5 evaluation periods means the alarm considers 5 consecutive 1-minute data points. The alarm only transitions to ALARM when all five periods breach the threshold (by default). You can configure datapoints-to-alarm to require only M out of N periods to breach — for example, 3 out of 5 — which reduces false positives from transient spikes.
# Alarm that requires 3 out of 5 periods to breach (reduces false positives)
aws cloudwatch put-metric-alarm \
--alarm-name CPUSpike \
--metric-name CPUUtilization \
--namespace AWS/EC2 \
--dimensions Name=AutoScalingGroupName,Value=my-asg \
--statistic Average \
--period 60 \
--evaluation-periods 5 \
--datapoints-to-alarm 3 \
--threshold 80 \
--comparison-operator GreaterThanThreshold \
--alarm-actions arn:aws:autoscaling:us-east-1:111122223333:scalingPolicy:...Composite Alarms: Combining Multiple Alarms
A composite alarm evaluates the state of multiple other alarms using Boolean logic (AND, OR, NOT). It enters the ALARM state only when its rule expression evaluates to true. Composite alarms are used to reduce alert noise — for example, only alert if BOTH high CPU AND high latency alarms are firing simultaneously, because high CPU alone may be acceptable during batch processing. You can also use composite alarms to suppress child alarms during maintenance windows.
# Create a composite alarm (alerts only when BOTH CPU and latency are high)
aws cloudwatch put-composite-alarm \
--alarm-name HighLoadComposite \
--alarm-rule 'ALARM("HighCPUAlarm") AND ALARM("HighLatencyAlarm")' \
--alarm-actions arn:aws:sns:us-east-1:111122223333:CriticalOps \
--alarm-description 'Alert only when both CPU and latency are elevated'Alarm Suppression with Composite Alarms
Composite alarms support alarm suppression actions — you can configure a composite alarm to suppress its child alarms during planned maintenance. For example, during a deployment window you might set a composite alarm that combines a 'MaintenanceMode' alarm with OR logic, suppressing all child alarm notifications while maintenance is active. This prevents an avalanche of alerts when you intentionally take services offline for upgrades.
# Composite alarm with suppression: alert UNLESS maintenance is active
aws cloudwatch put-composite-alarm \
--alarm-name ProductionAlerts \
--alarm-rule 'ALARM("HighCPUAlarm") AND NOT ALARM("MaintenanceModeAlarm")' \
--alarm-actions arn:aws:sns:us-east-1:111122223333:ProductionOpsIntegration with Auto Scaling Policies
Auto Scaling groups use CloudWatch alarms as triggers for step scaling and simple scaling policies. When the alarm enters the ALARM state, the scaling policy executes. For step scaling, you define multiple scaling adjustments for different threshold ranges — for example, add 1 instance if CPU is 70-80%, add 3 if CPU is 80-90%, add 5 if CPU is above 90%. The alarm triggers the first applicable step based on the breach level at evaluation time.
# Create a scale-out alarm linked to an ASG scaling policy
aws cloudwatch put-metric-alarm \
--alarm-name ScaleOutTrigger \
--metric-name CPUUtilization \
--namespace AWS/EC2 \
--dimensions Name=AutoScalingGroupName,Value=my-asg \
--statistic Average \
--period 60 \
--evaluation-periods 2 \
--threshold 70 \
--comparison-operator GreaterThanThreshold \
--alarm-actions arn:aws:autoscaling:us-east-1:111122223333:scalingPolicy:POLICY_ARNCloudWatch Billing Alarms
You can create billing alarms in CloudWatch to be notified when your estimated AWS charges exceed a threshold. Billing metrics are only published in the us-east-1 Region (regardless of where your resources run) and are updated approximately every 6 hours. To enable billing alarms, you must first turn on Billing Alerts in the AWS Billing console. The more precise tool is AWS Budgets, but CloudWatch billing alarms remain a valid option tested in the exam.
# Create a billing alarm for $100 threshold
aws cloudwatch put-metric-alarm \
--region us-east-1 \
--alarm-name MonthlyBillingAlert \
--alarm-description 'Alert when estimated charges exceed $100' \
--metric-name EstimatedCharges \
--namespace AWS/Billing \
--dimensions Name=Currency,Value=USD \
--statistic Maximum \
--period 86400 \
--evaluation-periods 1 \
--threshold 100 \
--comparison-operator GreaterThanThreshold \
--alarm-actions arn:aws:sns:us-east-1:111122223333:BillingAlertsTesting and Monitoring Alarms
You can manually set an alarm state using the set-alarm-state command to test alarm actions without waiting for a real threshold breach. This is useful for verifying that your SNS topics, Auto Scaling policies, and Lambda functions respond correctly. Always test your alarm actions in a non-production environment and verify that the SNS topic has the correct email subscriptions confirmed before relying on alarms for production alerting.
# Manually trigger an alarm for testing (does NOT persist — reverts on next evaluation)
aws cloudwatch set-alarm-state \
--alarm-name HighCPUAlarm \
--state-value ALARM \
--state-reason 'Testing alarm action'
# Watch alarm state history
aws cloudwatch describe-alarm-history \
--alarm-name HighCPUAlarm \
--history-item-type StateUpdate \
--query 'AlarmHistoryItems[].{Time:Timestamp,Summary:HistorySummary}'Quick Check
Test your understanding of AWS Solutions Architect (SAA-C03) concepts from this lesson.
Lesson Recap
In this lesson you learned: alarms have three states (OK, ALARM, INSUFFICIENT_DATA) and can trigger SNS, Auto Scaling, and EC2 actions, datapoints-to-alarm allows M-of-N evaluation to reduce false positives, and composite alarms use Boolean logic to combine multiple alarms and suppress alert noise. Next up we explore CloudWatch Logs and Log Insights for centralised log management.
Frequently asked questions
Is the “CloudWatch Alarms and Composite Alarms” lesson free?
Yes — the full text of “CloudWatch Alarms and Composite Alarms” is free to read here on the web, and the AWS Solutions Architect course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS Solutions Architect course, upgrade to CoddyKit PRO.
What will I learn in “CloudWatch Alarms and Composite Alarms”?
Set threshold-based alarms to trigger Auto Scaling or SNS notifications, and combine multiple alarms into a composite alarm to reduce alert noise. You practise AWS Solutions Architect with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start AWS Solutions Architect?
No prior experience is required. AWS Solutions Architect on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “CloudWatch Alarms and Composite Alarms” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this AWS Solutions Architect lesson?
Yes. Every AWS Solutions Architect lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- CloudWatch Metrics, Namespaces, and Dimensions
- CloudWatch Alarms and Composite Alarms
- CloudWatch Logs and Log Insights
- CloudWatch Dashboards and Container Insights