Skip to main content
Hi everyone — this lesson shows how to configure advanced alarms and notifications in Amazon CloudWatch, including anomaly-detection alarms, SNS notifications, metric alarms, and composite alarms.
Before you begin, confirm you have an EC2 instance in the running state with passed status checks and an open CloudWatch console in your browser. This walkthrough uses the EC2 instance’s per-instance metrics (CPU, NetworkIn, NetworkOut).

Prerequisites

  • An EC2 instance in the Running state with status checks passed.
  • AWS Console access with permissions for CloudWatch and SNS.
  • CloudWatch open in another browser tab.

Step 1 — Navigate to your EC2 metric

  1. In the AWS Console, open CloudWatch → Metrics → All metrics.
  2. Search for EC2 and choose Per-Instance Metrics.
  3. Copy your EC2 instance ID from the EC2 console and paste it into the metric search box, then press Enter. The metrics for that instance will appear (Instance Name and ID are shown).
  4. Select the checkbox for CPUUtilization.
A screenshot of the AWS CloudWatch Metrics console (us-east-1) showing an untitled time-series graph and a table of EC2 instance metrics. The list includes metrics like CPUUtilization, EBSReadBytes and EBSWriteBytes, with no alarms shown.

Step 2 — Create an anomaly-detection alarm for CPU

Anomaly detection models build an expected range (a prediction band) from historical metric values and trigger only when the metric moves outside that band. This is useful for metrics with consistent historical patterns where a static threshold would either miss anomalies or generate noise.
  1. With CPUUtilization graphed, click Create alarm (bell icon on the right of the metric).
  2. In the Create alarm flow:
    • Data source: CloudWatch metrics
    • Type: Single metric
    • Metric name: CPUUtilization for your instance
    • Period/statistic: Use the defaults (for example, 5-minute period)
  3. For Threshold type choose Anomaly detection. The alarm will compare metric values against the predicted band instead of a fixed threshold.
A screenshot of the AWS CloudWatch "Create alarm" page showing the Metric panel for an EC2 instance (Namespace: AWS/EC2, Metric name: CPUUtilization) and the Conditions section with threshold options (Static vs Anomaly detection). The interface also shows instance details, a 5-minute period selection, and a preview area.
  1. The preview shows the prediction band (expected range). If the metric moves outside that band, the anomaly-detection alarm will transition to ALARM.
A screenshot of the AWS CloudWatch "Create alarm" page showing a highlighted "Prediction band preview" warning about anomaly detection and a "Conditions" section with threshold options including Anomaly detection. The browser tab bar and AWS navigation header are visible at the top.

Step 3 — Set evaluation periods (M out of N)

Under Additional configuration set Data points to alarm to 3 out of 5. This means CloudWatch evaluates 5 periods and requires at least 3 breaches to trigger ALARM. This reduces false positives from one-off spikes and detects sustained anomalies.

Step 4 — Configure notifications (SNS)

  • For Alarm state trigger choose In alarm.
  • Choose an SNS topic to receive notifications. If you don’t have one yet, create a new SNS topic and add an email endpoint. Note: subscriptions must be confirmed from the recipient email before SNS will deliver notifications.
A screenshot of the AWS CloudWatch "Create alarm" page showing the Notification configuration, with options for alarm state triggers ("In alarm", "OK", "Insufficient data"). The left sidebar shows the setup steps (Configure actions, Add alarm details, Preview and create).

Create the SNS topic and confirm subscription

  • Create the topic, add your email endpoint, and finish the alarm creation. The CloudWatch UI shows that some subscriptions are pending confirmation. Confirm the subscription from the email you receive so notifications will be delivered.
A screenshot of the AWS CloudWatch "Create alarm" page. It shows creating an SNS topic named "Default_CloudWatch_Alarms_Topic" with the email endpoint developercloud29@gmail.com and buttons labeled "Create topic" and "Add notification."
A screenshot of the AWS CloudWatch Alarms console showing a green confirmation banner saying "Successfully created alarm AnomalyDetection1." Below it is a blue info banner warning "Some subscriptions are pending confirmation" with a "View SNS Subscriptions" button and the Alarms list controls visible.
A screenshot of the AWS Management Console showing the Amazon SNS "Subscriptions" page, with one email subscription listed as "Pending confirmation" for a CloudWatch alarms topic. The page includes buttons like Create subscription, Confirm subscription, Edit, and Delete.
A web browser screenshot of an AWS Simple Notification Service page showing "Subscription confirmed!" with the subscription ARN and a link to unsubscribe. The page confirms successful subscription to a CloudWatch alarms topic.
Result: After confirming the subscription, CloudWatch can send email notifications when the anomaly-detection alarm enters ALARM. The alarm status will also appear on the EC2 instance details page under Status and alarms.

Step 5 — Create additional metric alarms (NetworkIn and NetworkOut)

We’ll create two static threshold alarms and later combine them into a composite alarm.
  1. In CloudWatch Metrics, browse to your instance and select NetworkIn. Click Create alarm.
    • Use a Static threshold (for example: Greater than 1,700,000 bytes for the evaluation period).
    • Select the same SNS topic (or another) for notifications.
    • Name it NetworkInAlarm.
A screenshot of the AWS CloudWatch "Create alarm" console showing the Metric and Conditions panels. It displays settings for an EC2 metric (NetworkIn) including instance ID, statistic (Average), period, and threshold type (Static/Anomaly detection).
  1. Repeat for NetworkOut and create NetworkOutAlarm. For example, set a static threshold like 20,000 bytes if appropriate for your workload.
A screenshot of the AWS CloudWatch Metrics page showing time-series graphs for CPUUtilization, NetworkIn, and NetworkOut with controls for timeframe, actions, and queries. The interface shows region (N. Virginia), filter/search fields, and buttons like "Create alarm" and "Add query."
If thresholds are generating noisy alerts, edit the alarm’s condition and raise the threshold or increase the evaluation periods.
A screenshot of the AWS CloudWatch "Edit alarm" page showing alarm condition options with "Greater" selected and the threshold set to 9,000,000, and a "Next" button visible. The breadcrumb shows CloudWatch > Alarms > NetworkInAlarm.
A screenshot of the AWS CloudWatch console showing a "NetworkOutAlarm" alarm page with the Actions dropdown menu open. A time-series graph of the NetworkOut metric is visible on the right with an "In alarm" indicator.

Confirm alarms firing

If thresholds are exceeded and subscriptions are confirmed, you should receive notification emails for NetworkInAlarm or NetworkOutAlarm.
A screenshot of a Gmail inbox displaying an AWS Notifications email titled "ALARM: 'NetworkInAlarm' in US East (N. Virginia)" describing a CloudWatch alarm. The message content and links to the AWS console are visible with standard Gmail UI elements.

Step 6 — Create a composite alarm

Composite alarms evaluate the states of other CloudWatch alarms (child alarms) using boolean logic (AND/OR). Composite alarms do not evaluate metrics directly; they operate on child alarm states.
  1. In CloudWatch Alarms, choose Create composite alarm.
  2. Select the member alarms (e.g., NetworkInAlarm, NetworkOutAlarm).
  3. Define the logic expression:
    • OR: triggers if any child alarm is ALARM.
    • AND: triggers only if all child alarms are ALARM.
  4. Configure the In alarm action (SNS topic), name the composite alarm (e.g., CompositeAlarm1), and create it.
A screenshot of the AWS CloudWatch "Create alarm" page showing the "Configure actions" step. It displays notification settings with the "In alarm" trigger selected and options to choose an SNS topic.
Result: composite alarm created
A screenshot of the AWS CloudWatch Alarms console showing a green banner that says "Successfully created alarm CompositeAlarm1" and a list of alarms (e.g., CompositeAlarm1, NetworkInAlarm) with their OK states. The page includes buttons for creating alarms, actions, and filtering.

Composite alarm view

The composite alarm details show it as a parent alarm and list its child metric alarms. Composite alarms display state timelines (not metric time series).
Screenshot of the AWS CloudWatch Alarms console showing a composite alarm named "CompositeAlarm1" with child metric alarms (NetworkInAlarm, NetworkOutAlarm) listed as OK. A timeline/graph and action buttons are visible at the top.
A screenshot of the AWS CloudWatch console showing the "CompositeAlarm1" alarm details page, including its state (OK), last state update, and ARN. The left sidebar with CloudWatch navigation and top browser tabs are also visible.
Screenshot of the AWS CloudWatch console on a CompositeAlarm1 details page, showing a timeline of alarm state changes and a left-hand navigation menu. The page includes time-range controls, action/investigate buttons, and a legend for alarm states.

Important: Deleting composite and member alarms (order-of-operations)

Composite alarms reference member alarms. You must delete composite alarms before deleting the child metric alarms that are part of them; otherwise the delete operation will fail.
Delete composite alarms first. Only after removing the composite alarm can you delete the member metric alarms (e.g., NetworkInAlarm, NetworkOutAlarm).
To delete alarms:
  1. In CloudWatch Alarms, select the composite alarm (e.g., CompositeAlarm1) → Actions → Delete.
  2. After the composite is deleted, select and delete the individual metric alarms.
  3. Finally, delete the anomaly detection alarm and any SNS topics/subscriptions if no longer needed.
Example console link (open in your region/console):
A screenshot of the AWS CloudWatch Alarms console with a confirmation dialog asking "Delete AnomalyDetection1?" to permanently delete the alarm. The dialog shows Cancel and a highlighted Delete button.

Removing anomaly detection models from graphed metrics

Deleting an anomaly-detection alarm does not always remove the prediction band from a graphed metric. To remove it entirely:
  • Open Metrics → Graphed metrics, select the metric (e.g., CPUUtilization) and delete the anomaly detection model from the graphed metrics list.
A screenshot of the AWS CloudWatch Metrics console showing a CPUUtilization time-series graph with a small spike and anomaly detection band. The page also shows metric controls and a list of graphed metrics (EC2 CPUUtilization) with options to add queries and math.
A screenshot of the AWS CloudWatch Metrics console showing a "Delete model" confirmation dialog warning about deleting the anomaly detection model for the "CPUUtilization" metric. The dialog includes explanatory text and "Cancel" and "Delete" buttons over the metrics dashboard.
After deleting the model, refresh the graph and the prediction band will be gone.

Quick reference — alarm types and when to use them

  • Use anomaly detection for metrics with clear historical patterns where adaptive thresholds reduce false positives.
  • Use static thresholds for simple, fixed limits that indicate definite violations.
  • Composite alarms model higher-level conditions across signals and help reduce alert noise by applying boolean logic to child alarm states.
  • Remember deletion order: delete composite alarms first, then member alarms, and then any SNS topics/subscriptions if needed.
Further reading: That covers configuring anomaly-detection alarms, SNS notifications, metric alarms, and composite alarms in this lesson.

Watch Video

Practice Lab