- Create an anomaly-detection alarm for CPU utilization
- Create static-threshold alarms for NetworkIn and NetworkOut
- Combine alarms into a composite alarm (AND / OR logic)
- Configure SNS notifications and confirm subscriptions
- Correctly delete composite and child alarms
- Remove lingering anomaly-detection models if they persist
Prerequisites
1) Create an anomaly-detection alarm for CPUUtilization
Navigate to CloudWatch → Metrics → All metrics → EC2 → Per-Instance Metrics. Copy your EC2 Instance ID from the EC2 console and paste it into the metrics search field to filter to your instance. Select theCPUUtilization metric and open Graphed metrics, then click the bell icon → Create alarm to start the Create alarm wizard.
- Data source: CloudWatch metrics
- Type: Single metric
- Metric:
CPUUtilizationfor your InstanceId



SNS reminder: subscriptions are pending confirmation until the recipient clicks the confirmation link in the email. CloudWatch will not send alarm notifications to that endpoint until the subscription is confirmed.


CPUUtilization that notifies the chosen SNS topic when 3 out of 5 datapoints fall outside the prediction band.
2) Create a NetworkIn static-threshold alarm
Return to Metrics → All metrics → EC2 → Per-Instance Metrics and selectNetworkIn for your instance. Add it to Graphed metrics and click Create alarm.
Choose a static threshold type and set a value appropriate for your workload (the demo used ~1.7 million bytes as an example). Configure Statistic and Period (e.g., Average over 5 minutes) to match your monitoring needs.


NetworkInAlarm) and finish the wizard.

3) Create a NetworkOut static-threshold alarm
Follow the same process forNetworkOut: add it to Graphed metrics, choose a static threshold (demo used > 20,000 bytes as an example), select Statistic and Period, attach an SNS topic, and name the alarm NetworkOutAlarm.



4) Create a Composite Alarm
Composite alarms evaluate the states of other alarms rather than metrics, letting you express higher-level logic such as “only alert if both NetworkIn and NetworkOut are anomalous”. From the Alarms console, select the child alarms to combine (e.g.,NetworkInAlarm and NetworkOutAlarm) and choose Create composite alarm. Compose the expression using ALARM("AlarmName"):
- AND logic (both must be ALARM):
- OR logic (either one triggers):



5) Deleting alarms — ordering matters
When using composite alarms, always delete composite alarms before deleting any child alarms referenced by them. Attempting to delete a child alarm that a composite alarm references will fail. Example composite alarm ARN:- Delete the composite alarm first (Actions → Delete).
- After the composite alarm is removed, delete each child alarm (e.g.,
NetworkInAlarm,NetworkOutAlarm). - Finally, delete any remaining alarms such as the anomaly-detection alarm if no longer needed.
Important: delete composite alarms before their child alarms. Deleting in the wrong order will fail and may leave alarms in a referenced state.
6) Removing lingering anomaly-detection models
Occasionally an anomaly-detection band may remain visible in the metric graph after you delete the alarm. Remove the anomaly model explicitly:- Go to Metrics → Graphed metrics for the affected metric (e.g.,
CPUUtilization). - Choose the metric and use the Delete model option to remove the anomaly detection model.
- Confirm deletion in the dialog, then refresh the console to clear the anomaly band.

Best practices
- Use anomaly detection for adaptive metrics (CPU, latency) where baselining behavior yields better signal/noise.
- Use static thresholds for simple signals (NetworkIn/NetworkOut) when a fixed cutoff is appropriate.
- Use composite alarms to reduce noise and surface only actionable conditions (AND/OR logic).
- Confirm SNS subscriptions promptly to ensure alerts are delivered.
- Tune evaluation periods and datapoints (e.g., “3 out of 5”) to balance sensitivity and false positives.
- Always delete composite alarms before deleting child alarms.
Summary
- Anomaly detection: adaptive, ideal for CPU/latency patterns.
- Static thresholds: predictable, ideal for network volume cutoffs.
- Composite alarms: combine child alarm states into a single, actionable alert.
- SNS: confirm subscriptions to receive notifications.
- Deletion order: composite first, then child alarms.
- Clean up anomaly models if they persist after alarm deletion.
Links and references
- Amazon CloudWatch Alarms documentation
- Anomaly detection in CloudWatch
- Amazon SNS topics and subscriptions