Rate and irate display very different values

Hello,
I’ve got the two following sentences on two different graphs:
rate(node_disk_bytes_read{job=“node_exporter”}[5m])
irate(node_disk_bytes_read{job=“node_exporter”}[5m])
The unit is bytes.
As you can see in the attached image, on one graph the maximum reaches almost 12MiB, whereas in the other it reaches about 650KiB.

Any idea what is happening?

1 Like

irate uses only two last data points on each interval between subsequent pixels (aka step), while rate calculates average per-second rate over all the data points on each interval. Read more here.

So this would be a correct representation then, right?

No, irate doesn’t capture spikes - it just returns random sample of data points for the given time series. On the other hand, rate consistently returns the average rate over the duration in square brackets.

If you want capturing spikes, then take a look at rollup_rate function from VictoriaMetrics’ Extended PromQL. It is explained in details in the article mentioned above.

Yeah, my question was, if this is what grafana is supposed to show, given that query. Not necessarily if the query is doing what is intended. Thanks for the tip :slight_smile: