Skip to content

Instantly share code, notes, and snippets.

Created Jun 15, 2022
What would you like to do?
PromQL notes

Ch13 - Intro to PromQL

Aggregating gauges

We have a gauge metric called: node_filesystem_size_bytes

        instance="localhost:9100",job="node",mountpoint="/boot/efi"} 70300672
        instance="localhost:9100",job="node",mountpoint="/"} 30791843840
        instance="localhost:9100",job="node",mountpoint="/run"} 817094656
        instance="localhost:9100",job="node",mountpoint="/run/lock"} 5238784
        instance="localhost:9100",job="node",mountpoint="/run/user/1000"} 826912768

The following statement aggregates the metric and sum() its values.

sum without(device, fstype, mountpoint)(node_filesystem_size_bytes)

Notice the result:

{instance="localhost:9100",job="node"} 32511390720

The metric name is gone and we only have the instance label.


Counters track the number of events. The metric increases over time. It is useless in raw format, what we want is a way to see how it changes over time. We have the rate function, increase and the irate function to operate on counter values.

The metric node_network_receive_bytes_total returns the following time series:

node_network_receive_bytes_total{device="eth0", instance="node-exporter:9100", job="node"} 375063
node_network_receive_bytes_total{device="lo", instance="node-exporter:9100", job="node"} 0

Now we can compute the rate on that metric on 5 minute windows:


And we get:

{device="eth0", instance="node-exporter:9100", job="node"} 36.86666666666667
{device="lo", instance="node-exporter:9100", job="node"} 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment