1. Who does what? #
Prometheus detects, Alertmanager notifies.
Splitting the roles #
Prometheus periodically evaluates alerting rules (PromQL expressions). When a rule is true, it sends the alert (with its labels and annotations) to Alertmanager, and resends it regularly as long as it is active.
Alertmanager knows nothing about PromQL: it receives alerts and decides whom to notify, when and how.
| Function | Effect |
|---|---|
| Deduplication | An alert received from two Prometheus servers or ten times in a row is notified only once |
| Grouping | 50 instances down = a single « 50 instances down » notification |
| Routing | The database alert goes to the DBA team, the front-end one to the web team |
| Silences | Temporarily mute notifications (maintenance) |
| Inhibitions | Mute secondary alerts when a main alert is active |
| Time intervals | Do not wake people up at night for a non-urgent alert |
2. The lifecycle of an alert #
Pending, firing, resolved.
The states #
groups:
- name: disponibilite
rules:
- alert: InstanceDown
expr: up == 0
for: 5m # doit rester vraie 5 min avant de passer en firing
keep_firing_for: 2m # évite le clignotement firing/resolved
labels:
severity: critical
team: plateforme
annotations:
summary: "{{ $labels.instance }} ne répond plus"
runbook_url: https://wiki.example.org/runbooks/instance-downGood to know: When the expression becomes false again, Prometheus sends the alert with an end date: Alertmanager then notifies the resolution if the receiver has send_resolved: true (the default for most integrations).3. Installing Alertmanager #
One binary, one configuration file.
Startup #
docker run -d --name alertmanager -p 9093:9093 \
-v $PWD/alertmanager.yml:/etc/alertmanager/alertmanager.yml \
prom/alertmanager:latest# prometheus.yml : où envoyer les alertes
alerting:
alertmanagers:
- static_configs:
- targets: ["alertmanager:9093"]
rule_files: ["rules/*.yml"]The web interface (:9093) lists received alerts, their groups and silences. The amtool command-line tool does the same from a terminal.
