Sub topic 16
Routing Alerts with Alertmanager
Assume you already know how Prometheus evaluates alerting rules and labels alert series. This chapter focuses on what happens after an alert fires: grouping, routing, notification, and recovery.
What Alertmanager does
Prometheus detects a condition and sends an alert to Alertmanager. Alertmanager then decides how to handle it. It can:
- Group related alerts into one notification.
- Route different alerts to different receivers.
- Suppress duplicate notifications.
- Silence alerts during planned maintenance.
- Inhibit lower-priority alerts when a higher-priority alert already explains the problem.
- Send notifications when alerts fire and when they resolve.
Prometheus should answer, “Is there a problem?” Alertmanager should answer, “Who should know, and how often?”
Configure routes and receivers
A receiver defines a notification destination. A route chooses a receiver by matching alert labels. The following configuration groups alerts by alert name and server, waits briefly for related alerts, and sends them to a webhook:
route:
receiver: team
group_by: ['alertname', 'instance']
group_wait: 30s
group_interval: 5m
repeat_interval: 4h
receivers:
- name: team
webhook_configs:
- url: http://localhost:5001/alertsThe main settings are:
| Setting | Purpose |
|---|---|
| `group_by` | Labels that identify alerts belonging in one notification |
| `group_wait` | Delay before sending the first notification for a new group |
| `group_interval` | Minimum delay before notifying about changes in an existing group |
| `repeat_interval` | Delay before repeating an unresolved alert |
| `receiver` | Default notification destination |
A short group_wait reduces delay but can produce more messages. A longer value allows several alerts caused by one incident to arrive together. The repeat interval should match the urgency of the alert and the team's notification policy.
Route by severity
Child routes let you send critical alerts to an on-call system while sending warnings to a general channel:
route:
receiver: team
routes:
- matchers:
- severity="critical"
receiver: oncall
continue: false
- matchers:
- severity="warning"
receiver: team
receivers:
- name: oncall
webhook_configs:
- url: http://localhost:5001/oncall
- name: team
webhook_configs:
- url: http://localhost:5001/alertsLabels are part of the routing contract. If an alert rule does not set severity: critical, it cannot match the critical route.
After changing the configuration, validate it with the amtool utility when available, then reload or restart Alertmanager. Inspect its logs and send a test alert. The Alertmanager web interface also shows active alerts, silences, and the configured routing tree.
Exercise
An alert has the label severity="warning", but it reaches the oncall receiver that matches severity="critical". What should you check first?
Show answer
Check the alert's actual labels and the route matchers. Also verify that the intended child route is loaded and that an earlier route is not using continue or a different receiver.