Sub topic 13
Reducing alert noise with composite alarms
This chapter assumes you can create a metric alarm and attach an SNS topic to it, as covered in the earlier chapters on alarms and alarm actions. It also assumes you are comfortable with the AWS CLI.
The problem: one incident, many alerts
A single failure often trips several metric alarms at once. If a web server fails, you may see high CPU, high latency, and a rising error count within the same few minutes. If each alarm notifies the on-call engineer, they get three messages about one problem.
A composite alarm is an alarm whose state is computed from the states of other alarms. It does not read metric data itself. You write a rule expression that combines existing alarms, and the composite alarm goes to ALARM when the expression evaluates to true.
Rule expressions
The rule uses these functions and operators:
ALARM("name")is true when that alarm is in the ALARM state.OK("name")is true when that alarm is in the OK state.INSUFFICIENT_DATA("name")is true when that alarm has too little data.AND,OR, andNOTcombine the results. Parentheses group them.
Alarms that feed a composite alarm are called its child alarms. You can refer to an alarm by name or by ARN.
Worked example
Suppose high-cpu-web already exists from the previous chapter. Suppose you also have high-latency-web. You want one notification only when both are in ALARM, because either one alone is often a short spike.
aws cloudwatch put-composite-alarm \
--alarm-name web-degraded \
--alarm-rule 'ALARM("high-cpu-web") AND ALARM("high-latency-web")' \
--alarm-actions arn:aws:sns:us-east-1:111122223333:ops-alertsThe composite alarm web-degraded now sends the message. The child alarms should have no alarm actions of their own. If they keep their SNS actions, you still get three notifications and nothing is reduced.
Diagram
Suppressing alerts during maintenance
Composite alarms can also mute notifications. Use --actions-suppressor to name an alarm that, while in ALARM, stops the composite alarm from running its actions. Use this when you already know a problem exists and do not want repeat alerts for its side effects.
aws cloudwatch put-composite-alarm \
--alarm-name web-degraded \
--alarm-rule 'ALARM("high-cpu-web") OR ALARM("high-latency-web")' \
--actions-suppressor deploy-in-progress \
--actions-suppressor-wait-period 120 \
--actions-suppressor-extension-period 60 \
--alarm-actions arn:aws:sns:us-east-1:111122223333:ops-alertsThe wait period is how many seconds the suppressor alarm is given to reach ALARM before the composite alarm acts. The extension period is how many seconds the actions stay suppressed after the suppressor leaves ALARM.
Common errors
- Deleting a child alarm. You cannot delete an alarm that a composite alarm references. Update the composite rule first.
- Leaving actions on child alarms. This keeps the noise you meant to remove.
- Expecting data-based settings. A composite alarm has no threshold, period, or missing-data setting. Tune those on the child alarms.
- Circular references. A composite alarm cannot depend on itself, directly or through other composites.
Exercise
You have alarms error-rate-high and queue-depth-high. You want one SNS notification only when both are in ALARM. Which rule expression do you use, and where should the SNS action be attached?
Show answer
Use ALARM("error-rate-high") AND ALARM("queue-depth-high") as the rule of a composite alarm. Attach the SNS action to the composite alarm and remove it from the two child alarms.