Linux Labs

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

Metrics, exporters and scraping

Not running Starting usually ~20 s
Leave the lesson

Step 6 of 7 · lab · 20 minmedium

A machine dropped out of monitoring

Since last night Prometheus has had no data on this server's CPU, memory and disks, although Prometheus itself is running. Bring the machine back into monitoring so that it stays there.

Situation

This server is watched by the office monitoring. Prometheus runs right here: every 5 seconds it scrapes the metrics of the machine itself — CPU, memory, disks, network — from the node_exporter exporter. In the Prometheus configuration this is the node job.

Since last night the machine's graphs have been empty, and the on-call summary shows its up as 0. Meanwhile Prometheus keeps scraping its own metrics just fine.

There is no browser to the machine, so look at Prometheus from the terminal: queries — promtool query instant http://localhost:9090 '<query>', its API — curl -s localhost:9090/api/v1/… and jq. sudo works without a password.

Task

  1. The node job's target in Prometheus is up: promtool query instant http://localhost:9090 'up{job="node"}' prints => 1.
  2. node_exporter runs as the prometheus-node-exporter service; the service is enabled and listens on port 9100.
  3. The settings are saved in files: promtool check config /etc/prometheus/prometheus.yml passes, Prometheus runs with what the file says, the prometheus service is enabled — after the services restart the machine stays in monitoring.

Constraints

  • node_exporter listens on port 9100 on every office server — that is how the other Prometheus servers find the machine.
  • The node job stays in /etc/prometheus/prometheus.yml under its own name.

What Prometheus knows about each of its targets — the scrape address, the state and the last error — is shown by curl -s localhost:9090/api/v1/targets | jq '.data.activeTargets[] | {scrapeUrl, health, lastError}'

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 3
  • The node job's target in Prometheus is up — not done yet
  • node_exporter runs as the prometheus-node-exporter service, is enabled and listens on port 9100 — not done yet
  • The settings live in files; promtool check config passes, Prometheus runs with what is in prometheus.yml, the prometheus service is enabled — not done yet
Ctrl+Enter
Starts the machine node1 · Ubuntu 24.04

The machine is starting

Hints

0 of 3

Lab goals

0 of 3
  • The node job's target in Prometheus is up — not done yet
  • node_exporter runs as the prometheus-node-exporter service, is enabled and listens on port 9100 — not done yet
  • The settings live in files; promtool check config passes, Prometheus runs with what is in prometheus.yml, the prometheus service is enabled — not done yet
node1 Ubuntu 24.04

Lab goals

0 of 3
  • The node job's target in Prometheus is up — not done yet
  • node_exporter runs as the prometheus-node-exporter service, is enabled and listens on port 9100 — not done yet
  • The settings live in files; promtool check config passes, Prometheus runs with what is in prometheus.yml, the prometheus service is enabled — not done yet
Loading…