RousselTMLEARNING

Observability

Alertmanager: role, architecture and lifecycle of an alert

What Alertmanager does between Prometheus and your teams: deduplication, grouping, routing, silences and inhibitions, and the lifecycle of an alert from pending to resolved.

1. Who does what? #

Prometheus detects, Alertmanager notifies.

Splitting the roles #

Alerting architecture
Several Prometheus servers can send the same alerts: Alertmanager deduplicates them.

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.

FunctionEffect
DeduplicationAn alert received from two Prometheus servers or ten times in a row is notified only once
Grouping50 instances down = a single « 50 instances down » notification
RoutingThe database alert goes to the DBA team, the front-end one to the web team
SilencesTemporarily mute notifications (maintenance)
InhibitionsMute secondary alerts when a main alert is active
Time intervalsDo not wake people up at night for a non-urgent alert

2. The lifecycle of an alert #

Pending, firing, resolved.

The states #

Lifecycle
The for parameter avoids alerting on a spike lasting a few seconds.
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-down
Good 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.

Related articles

Writing good Prometheus alerting rules (and testing them)

Design useful alerts: alert on symptoms, choose for and thresholds, severity and team labels, annotations and…

Routing, grouping and receivers in Alertmanager

The Alertmanager routing tree: matchers, group_by, group_wait, group_interval, repeat_interval, continue, rec…

Silences, inhibitions and time intervals in Alertmanager

Reduce alert noise: one-off silences with amtool, inhibition rules (a critical alert mutes secondary alerts) …

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!