Linux Labs

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

Metrics, exporters and scraping

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 7 · on a machine · 4 min

Where is the free memory

What you will learn

  • Read an exporter's answer — metric name, labels, value and type — and find the figure you need in it.
  • Read the scrape state in Prometheus — the targets, their health and lastError, the up metric.
  • Add a Prometheus job for a new target — checking the config and reloading it without a restart.

The server is sluggish, and the on-call engineer asks: “Check the metrics for how much free memory there is.” Here the machine's figures are served by the node_exporter service — over HTTP, on port 9100. Ask it for the /metrics page, count the lines and find the memory lines. free -b is there for comparison.

Exercise · look

Look at the exporter's answer

The node_exporter service serves the machine's figures at localhost:9100/metrics. Count the lines in its answer, find the memory lines and compare them with the output of free -b.

First, predict

How many lines will node_exporter return?

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

The node_exporter of one machine returned about 1900 lines. What is in them?

  • The lines starting with # are descriptions: # HELP says what the metric counts, # TYPE gives its type. Look at curl -s localhost:9100/metrics | grep -m4 '^#'.

  • Repeat the request and you get about as many lines: the exporter returns the current values each time, with no history. Check with curl -s localhost:9100/metrics | wc -l again.

  • The exporter reads only its own machine — /proc and /sys; this VM has no outside network at all.

The exporter returns current values — a line for every number and a description for every metric.

Ubuntu 24.04
Loading…