Linux Labs

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

An alert rule: threshold and duration

Not running Starting usually ~20 s
Leave the lesson

Step 5 of 6 · lab · 30 minmedium

The full-volume alert stays silent

The volume with exports on the reports server has run out twice at night, and nobody found out. A colleague added an alert rule for an almost full volume to Prometheus, yet yesterday the volume filled up again with no alert. Make the alert fire in time and clear when the space is freed.

Situation

The reports server has a /srv/data volume where the nightly sales exports go. Two weeks ago it ran out of space at night, the reports were not built in the morning, and the team learned about it from accounting. A colleague added the DiskAlmostFull alert rule for an almost full volume to Prometheus — the rule files live in /etc/prometheus/rules/ — reloaded the configuration and went on holiday. Yesterday the volume filled up again. There was no alert.

Prometheus and node_exporter are running on the machine; metrics are scraped and rules are evaluated every 5 seconds. There is no browser: you see Prometheus only from the terminal — curl -s localhost:9090/api/v1/… | jq, promtool. sudo works without a password.

Task

  1. The DiskAlmostFull rule is loaded into the running Prometheus from the rule files, and promtool check config /etc/prometheus/prometheus.yml passes.
  2. When less than 10 % of /srv/data is free, the DiskAlmostFull alert fires — goes to the firing state — within a minute: the nightly export fills the volume quickly.
  3. When more than 10 % is free again, the alert clears.
  4. Prometheus and node_exporter are enabled and run with the settings from their files.

The check fills the volume with a temporary file itself, waits for the alert and deletes the file. You can test your rule the same way: sudo fallocate -l 50M /srv/data/test, and afterwards sudo rm /srv/data/test. Leave the exports in /srv/data/reports alone.

Lab · on your own

No commands are given in this lab: type them in the terminal yourself. Goals are checked on the machine after every command.

Goals

0 of 4
  • The DiskAlmostFull rule is loaded into the running Prometheus from the rule files, promtool check config passes — not done yet
  • When less than 10 % of /srv/data is free, the DiskAlmostFull alert fires — firing — within a minute — not done yet
  • When more than 10 % is free again, the alert clears — not done yet
  • Prometheus and node_exporter are enabled and run with the settings from their files — not done yet
Ctrl+Enter
Starts the machine node1 · Ubuntu 24.04

The machine is starting

Hints

0 of 3

Lab goals

0 of 4
  • The DiskAlmostFull rule is loaded into the running Prometheus from the rule files, promtool check config passes — not done yet
  • When less than 10 % of /srv/data is free, the DiskAlmostFull alert fires — firing — within a minute — not done yet
  • When more than 10 % is free again, the alert clears — not done yet
  • Prometheus and node_exporter are enabled and run with the settings from their files — not done yet
node1 Ubuntu 24.04

Lab goals

0 of 4
  • The DiskAlmostFull rule is loaded into the running Prometheus from the rule files, promtool check config passes — not done yet
  • When less than 10 % of /srv/data is free, the DiskAlmostFull alert fires — firing — within a minute — not done yet
  • When more than 10 % is free again, the alert clears — not done yet
  • Prometheus and node_exporter are enabled and run with the settings from their files — not done yet
Loading…