Linux Labs

Observability: metrics, alerts, logs / Final lab

The second machine is unwatched

hard ~75 min
Not running Starting usually ~20 s
Report a problem

Situation

A week ago the second machine, node2, was put under node1's watch and the ticket was closed. node1 runs Prometheus, Alertmanager and an rsyslog log collector. Alertmanager sends notifications for the on-call team to the lab-webhook training webhook: it appends every notification it receives as a line to /var/lib/lab-webhook/notifications.jsonl.

Yesterday node2 was down for half an hour, and nothing reached the on-call team. Digging in showed more: Prometheus on node1 does not see node2's metrics, and there are no fresh node2 logs on the collector.

node1 is your terminal. Run commands on node2 over SSH: ssh node2 'command', or enter its shell with ssh node2 and leave with exit. sudo works without a password on both machines. There is no browser to the machines: look at Prometheus and Alertmanager from the terminal — curl -s localhost:9090/api/v1/… | jq, promtool query instant http://localhost:9090 '<expression>', amtool alert.

Task

  1. Prometheus on node1 scrapes node2: the node2:9100 target in the node job is up.
  2. When node2 stops answering, the NodeDown alert about it (instance="node2:9100") becomes firing within a minute. While node2 works, NodeDown about it stays quiet.
  3. The notification about a firing NodeDown reaches the on-call team — as a new line in /var/lib/lab-webhook/notifications.jsonl.
  4. node2's logs are collected on node1: a line sent on node2 with logger shows up in a file in the /var/log/remote/node2/ directory on node1.

"Check" briefly stops the exporter on node2 (prometheus-node-exporter) by itself, sends a logger -t lab-verify … line from node2 and puts everything back. The check waits for the alert and the line and takes up to a minute and a half.

Constraints

  • Everything must survive a reboot of both machines: the services are enabled, the settings live in files, and the running services have re-read those files after your edits.
  • Do not turn off the firewall on node2 — open in it only what monitoring needs. Do not close SSH from node1 to node2: there is no other way into node2.
  • Leave the lab-webhook training webhook and its file alone.

There is no internet in the lab — only the network between node1 and node2, and everything you need is installed. Follow each chain from start to end and after every edit look at the result the way the check sees it: targets — curl -s localhost:9090/api/v1/targets | jq, alerts — curl -s localhost:9090/api/v1/alerts | jq and amtool alert, notifications — tail /var/lib/lab-webhook/notifications.jsonl, logs — logger on node2 and sudo ls -R /var/log/remote/ on node1.

Visible only to you. Saved as you type.

All notes

Lab goals

0 of 4
  • Prometheus on node1 scrapes node2 — the node2:9100 target in the node job is up; node2's firewall stays on, and all of it survives a reboot — not checked yet
  • When node2 stops answering, the NodeDown alert about it is firing within a minute, and while node2 works it stays quiet; the rule is loaded from its file — not checked yet
  • The notification about a firing NodeDown reaches the on-call team — the training webhook on node1; Prometheus and Alertmanager run with the settings from their files — not checked yet
  • A logger line from node2 shows up on node1 in /var/log/remote/node2/; rsyslog on both machines runs with the settings from its files and starts on its own — not checked yet

Hints

0 of 3 open · they open one at a time
Hint 1
Show the solution after 3 failed checks

Leave the lab?

The machine keeps running for 10 more minutes, then it is removed. Files are lost; completed goals stay.

Loading…