Observability: metrics, alerts, logs / Final lab
The second machine is unwatched
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
- Prometheus on node1 scrapes node2: the
node2:9100target in thenodejob isup. - When node2 stops answering, the
NodeDownalert about it (instance="node2:9100") becomesfiringwithin a minute. While node2 works,NodeDownabout it stays quiet. - The notification about a firing
NodeDownreaches the on-call team — as a new line in/var/lib/lab-webhook/notifications.jsonl. - node2's logs are collected on node1: a line sent on node2 with
loggershows 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-webhooktraining 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 | jqandamtool alert, notifications —tail /var/lib/lab-webhook/notifications.jsonl, logs —loggeron node2 andsudo ls -R /var/log/remote/on node1.
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