Linux Labs

Observability: metrics, alerts, logs / Stage 5 of 9

Alertmanager: to whom and how many times

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 6 · on a machine · 6 min

Fifty notifications for one event

What you will learn

  • Fold the alerts of one event into one notification with group_by and understand the group_wait, group_interval and repeat_interval timers.
  • Silence notifications for maintenance with amtool silence and check what is silenced.
  • Route alerts to receivers with a routing tree and check a route with amtool config routes test.

At night a switch rebooted, and 50 web servers dropped off the network for a couple of minutes. The on-call engineer woke up to 50 chat messages in a row. This machine has the same: Alertmanager received 50 InstanceDown alerts in one request, and the training webhook, standing in for the chat here, wrote down everything it was sent — one line per notification. Here the lesson setup sends the alerts through the Alertmanager API, just as Prometheus does.

Exercise · look

Count the notifications

Count how many notifications the training webhook wrote to /var/lib/lab-webhook/notifications.jsonl, and look at groupLabels of the first three.

First, predict

Alertmanager received 50 InstanceDown alerts in one request. How many notifications did the webhook write — one line per notification?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in
Check yourself 1 question

50 alerts reached Alertmanager in one request, yet there are 50 notifications, each with its own instance in groupLabels. Why?

  • All 50 came in one request to the Alertmanager API. Grouping is what split them: jq -c .groupLabels shows each notification with its own label set.

  • A line is a whole request from Alertmanager: jq '.alerts | length' over the file prints 1 on every line, because each notification holds one alert.

  • A resend would carry the same group labels, while here each line has its own instance. sudo journalctl -u lab-webhook shows 50 different groups.

Each notification has its own groupLabels — every alert ended up as a separate group.

Ubuntu 24.04
Loading…