Sub topic 13
Reducing alert noise with composite alarms
This chapter assumes you can create a metric alarm with put-metric-alarm, that you know the three alarm states (OK, ALARM, INSUFFICIENT_DATA), and that you have an SNS topic for notifications. If any of that is unfamiliar, review the chapters on metric alarms and alarm actions first.
The problem: one incident, many pages
A single fault often trips several alarms at once. When a database slows down, you might see high latency, a rising 5xx count, and high CPU on the web tier. If each alarm notifies the on-call engineer, they get three or four messages for one incident. Repeated noise like this trains people to ignore alerts.
A composite alarm is an alarm whose state comes from the states of other alarms, not from a metric. The alarms it reads are its child alarms. You write a rule that combines them with boolean logic. The composite alarm goes to ALARM when the rule evaluates to true. You then attach notifications to the composite alarm and leave the child alarms silent.
How a composite alarm works
A composite alarm has no metric, statistic, period, or threshold. It has an AlarmRule expression. The expression uses these functions and operators:
| Element | Meaning |
|---|---|
| `ALARM("name")` | True when the named alarm is in ALARM |
| `OK("name")` | True when the named alarm is in OK |
| `INSUFFICIENT_DATA("name")` | True when the named alarm is in INSUFFICIENT_DATA |
| `TRUE`, `FALSE` | Constants |
| `AND`, `OR`, `NOT` | Boolean operators |
| Parentheses | Grouping |
You can refer to an alarm by name or by its full ARN. A child can be a metric alarm or another composite alarm, but the references cannot form a cycle. A rule can reference a limited number of alarms, so check the current quota if you plan a large rule.
A composite alarm re-evaluates when a child alarm changes state. It does not wait for its own period, so it reacts as soon as the children do. The children still evaluate on their own periods and datapoint rules. A composite alarm therefore adds no extra detection speed. It only combines the results.
Step 1: create child alarms without actions
The child alarms record state but do not notify anyone. Leaving out --alarm-actions keeps them quiet. This example uses an Application Load Balancer. Replace the load balancer dimension value with your own.
aws cloudwatch put-metric-alarm \
--alarm-name alb-high-latency \
--namespace AWS/ApplicationELB \
--metric-name TargetResponseTime \
--dimensions Name=LoadBalancer,Value=app/my-alb/0123456789abcdef \
--statistic Average \
--period 60 \
--evaluation-periods 5 \
--datapoints-to-alarm 3 \
--threshold 1.5 \
--comparison-operator GreaterThanOrEqualToThreshold \
--treat-missing-data notBreaching
aws cloudwatch put-metric-alarm \
--alarm-name alb-high-5xx \
--namespace AWS/ApplicationELB \
--metric-name HTTPCode_Target_5XX_Count \
--dimensions Name=LoadBalancer,Value=app/my-alb/0123456789abcdef \
--statistic Sum \
--period 60 \
--evaluation-periods 5 \
--datapoints-to-alarm 3 \
--threshold 20 \
--comparison-operator GreaterThanOrEqualToThreshold \
--treat-missing-data notBreachingStep 2: create the composite alarm
Use put-composite-alarm and give it the rule and the notification target.
aws cloudwatch put-composite-alarm \
--alarm-name checkout-degraded \
--alarm-description "Latency and 5xx errors are both elevated" \
--alarm-rule 'ALARM("alb-high-latency") AND ALARM("alb-high-5xx")' \
--alarm-actions arn:aws:sns:us-east-1:111122223333:ops-alerts \
--ok-actions arn:aws:sns:us-east-1:111122223333:ops-alertsNow a latency spike alone changes only the child alarm's state. Nobody is paged until the 5xx alarm also fires. Setting --ok-actions sends a message when the incident ends, so people know they can stop watching.
You can check the result with describe-alarms. Composite alarms are returned in a separate list, so request them explicitly.
aws cloudwatch describe-alarms \
--alarm-types CompositeAlarm \
--alarm-names checkout-degradedChoosing a rule
The rule decides what kind of noise you remove. Three patterns cover most cases.
- Require agreement.
ALARM(a) AND ALARM(b)pages only when two independent symptoms appear together. This reduces false positives from a single flaky metric. The cost is that a real problem visible in only one metric will not page. - Group related alarms.
ALARM(a) OR ALARM(b) OR ALARM(c)turns many alarms into one notification. The composite alarm stays in ALARM while any child is in ALARM, so a second child failing during an incident does not produce a new message. - Ignore known conditions.
ALARM(a) AND NOT ALARM(maintenance-window)suppresses a page while a flag alarm is on. You can build the flag from a custom metric you publish during planned work.
Suppressing actions with an actions suppressor
A rule changes the composite alarm's state. An actions suppressor is different: the composite alarm still changes state, but its actions are held back while another alarm, the suppressor, is in ALARM. This suits cases where one alarm explains another. For example, you may not want a "service unhealthy" page while a "deployment in progress" alarm is active.
aws cloudwatch put-composite-alarm \
--alarm-name checkout-degraded \
--alarm-rule 'ALARM("alb-high-latency") OR ALARM("alb-high-5xx")' \
--alarm-actions arn:aws:sns:us-east-1:111122223333:ops-alerts \
--actions-suppressor deploy-in-progress \
--actions-suppressor-wait-period 120 \
--actions-suppressor-extension-period 180The two timing values are in seconds:
- The wait period is how long CloudWatch waits for the suppressor to enter ALARM after the composite alarm does. This covers the delay between a deployment starting and its alarm firing.
- The extension period is how long actions stay suppressed after the suppressor leaves ALARM. This covers the tail where the system is still settling.
If the suppressor stays quiet, actions run once the wait period ends. Note that put-composite-alarm replaces the earlier definition of checkout-degraded, so repeat every setting you want to keep.
Gotchas
- Missing data propagates. A child in INSUFFICIENT_DATA is neither ALARM nor OK. A rule such as
NOT ALARM(a)is true for both states, which may hide a monitoring gap. Set--treat-missing-dataon each child deliberately. - Child actions still run. If you leave
--alarm-actionson a child alarm, it still notifies on its own. Remove them when you move to a composite design. - Action types are limited. A composite alarm supports SNS notifications and Systems Manager actions. It does not support EC2 actions or Auto Scaling policies, so keep those on the metric alarm.
- Deleting a child is blocked or risky. A rule that references a missing alarm cannot evaluate correctly. Update or delete the composite alarm first.
- Cost. Each composite alarm is billed as an alarm, and you still pay for the children. Grouping saves attention, not money.
Exercise
A composite alarm has the rule ALARM("cpu-high") AND ALARM("queue-deep"). The cpu-high child has been in ALARM for an hour. The queue-deep child is in INSUFFICIENT_DATA because the queue metric stopped reporting. What state is the composite alarm in, and what should you change if you want a missing queue metric to be visible?
Show answer
The rule is false, because INSUFFICIENTDATA is not ALARM, so the composite alarm is not in ALARM and sends no notification. To make the gap visible, either set --treat-missing-data on queue-deep so missing data counts as breaching, or add a term such as `OR INSUFFICIENTDATA("queue-deep")` to the rule, or create a separate alarm for the missing metric.