If you need to calculate per-minute increase rate for a counter metric, then use increase(...[1m])
. For example, the following query returns the increase of processed_work_items_total{job="MainWorker"}
time series over the last minute:
increase(processed_work_items_total{job="MainWorker"}[1m])
Note that the increase()
function in Prometheus may return unexpected results due to the following issues:
- It may return fractional results over integer metric because of extrapolation. See this issue for details.
- It may miss counter increase between the last raw sample just before the lookbehind window specified in square brackets and the first raw sample inside the lookbehind window.
- It may miss the initial counter increase at the beginning of the time series.
These issues are going to be addressed in Prometheus according to this design doc. In the mean time it is possible to use MetricsQL, which is free from these issues.