🎓 A1Learner
🔍
0 of 50 lessons completed

Alertmanager: Routing and Grouping

Alertmanager is the part that takes firing alerts from Prometheus and sends them to people. A receiver is where a notification goes, and a route is the rule that picks which receiver gets which alert.

One receiver, a webhook

This receiver posts every alert it gets to a web address.

receivers:
  - name: 'webhook'
    webhook_configs:
      - url: 'http://127.0.0.1:19199/hook'

Routes by severity

Critical alerts go to one receiver, warnings to another.

routes:
  - matchers: ['severity="critical"']
    receiver: 'webhook-critical'
  - matchers: ['severity="warning"']
    receiver: 'webhook-warning'

Grouping and the three waits

Alerts group by name, then wait 30 seconds before the first message.

group_by: ['alertname']
group_wait: 30s
group_interval: 5m
repeat_interval: 1h

Example

amtool check-config alertmanager.yml

Key points

  • A receiver is one destination, like a webhook or an email address.
  • A route matches alerts by label, so a critical alert and a warning go to different receivers.
  • Grouping gathers alerts that belong together into one notification instead of one message each.
  • The group_by list names the labels that decide which alerts belong together.
  • group_wait is the short pause before the first notification for a new group.
  • group_interval is the wait before the next notification about the same group.
  • repeat_interval is how long Alertmanager waits before sending the same alert again.

In this example, amtool checks the real Alertmanager config on the lab machine and finds it valid, with one route, one inhibit rule, and three receivers. The config routes critical alerts to the critical webhook and warnings to the warning webhook, grouped by alert name.

Note

Grouping stops the flood, but it never hides an alert.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

What does group_wait do?