Linux Labs

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

PromQL: rate, sum and comparison

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 6 · on a machine · 5 min

How much traffic right now

What you will learn

  • Turn a counter into a rate over a window — rate and increase — and read the result.
  • Pick series by labels and add them up — sum by and sum without.
  • Divide series and compare them with a threshold — an error share and the > filter — from the terminal, through promtool and the API.

A colleague writes: “The machine's network looks busy — how much is it receiving right now?” Prometheus on the machine scrapes node_exporter, and that has the node_network_receive_bytes_total metric — bytes received on each network interface. Ask Prometheus for it twice, 10 seconds apart.

Exercise · look

Query the counter twice

Ask Prometheus for the node_network_receive_bytes_total metric, wait 10 seconds and ask again. Compare the two numbers.

First, predict

What will the second query show, 10 seconds after the first?

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

In 10 seconds the received-bytes counter grew by about 2 million. How many bytes per second was the machine receiving?

  • 300 million is everything that came through eth1 since it appeared. Per second it is the difference of the two numbers divided by 10.

  • 2 million arrived over all 10 seconds between the queries; per second it is 10 times less.

  • Two counter values and the time between them are enough: the growth divided by the seconds is the rate.

2 million bytes in 10 seconds is about 200 thousand bytes per second.

Ubuntu 24.04
Loading…