Alerting on Problems with Alarms, Events and Notifications
This lesson explains how alerts make sure the right people or systems hear about problems quickly, while avoiding so many notifications that real problems are ignored.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish alerts on measurements from alerts on events.
- Explain how to route alerts to avoid alert fatigue.
- Describe how an EventBridge rule notifies a team of a service event, such as a failed deployment.
- Explain how alarms on AWS/Usage metrics warn before a service quota is reached.
Sources of alerts
Alerts come from two kinds of signal, measurements and events, and AWS provides a different mechanism for each.
CloudWatch alarms alert on measurements. When a metric such as error rate, latency or queue depth crosses its threshold for long enough, the alarm changes state and publishes to an SNS topic, which delivers the notification by email, SMS, a chat channel or an HTTPS endpoint, or to a queue or function for automated handling.
EventBridge rules alert on events, which are things that happen once rather than values that rise and fall. AWS services publish state changes to the default event bus, such as a CodeDeploy deployment failing, a CodePipeline execution succeeding, a CloudFormation stack rolling back or an AWS Health notification about scheduled maintenance, and a rule can send matching events to SNS or another target without any polling. Limits are a third source: AWS publishes usage of many service quotas, such as Lambda concurrent executions, as CloudWatch usage metrics, so an ordinary alarm can warn before a quota is reached. The following table summarises the sources.
| Source | Use for |
|---|---|
| CloudWatch alarms → SNS | Metric thresholds |
| EventBridge rules | Events such as CodeDeploy or CodePipeline state changes, CloudFormation failures and AWS Health events |
| CloudWatch usage metrics (AWS/Usage namespace) | Warnings before you reach a limit, such as Lambda concurrency |
Routing alerts well
An alert is only useful if it reaches someone who can act on it and is not lost among many others. When teams receive too many alerts, especially ones that need no action, they start ignoring them, a condition known as alert fatigue, and then miss the alerts that matter.
Several practices prevent this. Alarms are routed to SNS topics by severity, so that urgent alarms page the on-call engineer while minor ones go to a ticket queue or a chat channel; Amazon Q Developer in chat applications delivers notifications to Slack and Microsoft Teams channels without custom code. Alerts are based on symptoms that users notice, such as error rate and latency, rather than on every possible cause, such as the CPU of each instance. An alarm should require several breaching data points, for example three out of five minutes, so that one brief spike does not wake anyone.
Finally, related alarms are combined into a composite alarm, whose state is a logical expression of other alarms, such as "high error rate AND high latency". The individual alarms keep their state for diagnosis but have no notification actions; only the composite alarm notifies, so one incident produces one page instead of a dozen.
Alerting on events
Example. Notify the team whenever a CodeDeploy deployment fails. AWS services publish state changes to the default event bus, so no polling is needed; the SNS topic's policy must allow events.amazonaws.com to publish.
aws events put-rule --name deploy-failed --event-pattern '{
"source": ["aws.codedeploy"],
"detail-type": ["CodeDeploy Deployment State-change Notification"],
"detail": {"state": ["FAILURE"]}
}'
aws events put-targets --rule deploy-failed \
--targets Id=notify,Arn=arn:aws:sns:eu-west-1:111122223333:deploymentsAlerting before a quota is reached
AWS publishes usage for many quotas, such as Lambda concurrent executions, as CloudWatch metrics in the AWS/Usage namespace. An alarm on the usage metric, for example at 80% of the quota, warns the team in time to request an increase before throttling starts. The SERVICE_QUOTA() metric math function compares usage with the current quota value.
Fewer, better alerts
An on-call developer receives 200 alerts a week, mostly from brief CPU spikes, and starts ignoring them. The team redesigns alerting around user impact:
| Before | After |
|---|---|
| Alarm on any CPU above 70% | Alarm on error rate and p99 latency, the symptoms users feel |
| Alarm on a single data point | Alarm when 3 of 5 one-minute periods breach |
| Separate alarms paging separately | A composite alarm pages only when errors AND latency are high |
| Every alarm pages someone | Low-priority alarms create tickets instead |
Pages drop to a handful a week, each of which matters. Dashboards show the CPU metrics for investigation without paging anyone.
How can a team be warned before the account reaches a service quota?
Show answer
Create a CloudWatch alarm on the quota's usage metric, for example from the Service Quotas console, at a threshold such as 80% of the quota, and send the alarm to an SNS topic.
Exam Tips
Remember for the exam
- To be notified of deployment success or failure, route an EventBridge rule to SNS.
- To be warned before hitting a quota, alarm on its CloudWatch usage metric.
- To send alarms to Slack or Microsoft Teams, use SNS with Amazon Q Developer in chat applications.
- To reduce alert noise, use composite alarms and require several breaching data points.
- Alert on user-facing symptoms such as error rate and latency rather than on every resource metric.