I'm using a PromQL query to calculate the cumulative traffic pushed/received through some interfaces on any node on the last 60 minutes. With Prometheus Node Exporter's metrics:
delta(node_network_receive_bytes_total{device=~"ens.*"}[60m])*8
And it's perfectly fine as far as the node does not reboot in that interval, the value is simply the difference between the vector's tip and its tail. When the system reboots and the counter resets, the meaning of the function stops reflecting said result.
e.g. Being this the graph for node_network_transmit_bytes_total
:
... the function will return -9MiB, instead of 10.2MiB.
I guess I can play out with rate()
s to get an estimate by also using the time. But is there a better function/way to get the actual thing?