PromQL - how to get an interval between result values

Viewed 223

Lets say I have a cronjob which is cleaning folder, but only if that folder reach some specific size.

And then, I save a unix timestamp when cleaning was executed. My results(timestamps) could be:

cleaning_executed{folder="foo"}
1631952000
1631963100
1632014400
1632112200

Is there any solution, to find the maximum/minimum interval between these results with PromQL?

1 Answers

Try to use the following query:

idelta(cleaning_executed{folder="foo"}[1h])

It will calculate the difference between the last two samples in the range returning a vector with the given deltas.

More info at the Prometheus documentation here.

Related