gti303
gti303

Reputation: 85

Prometheus/Grafana Rate()....what Unit for Y Axis

I have a counter that I am plotting on Grafana.


rate(processed_work_items_total{job="MainWorker"}[1m])

I am not getting the expected numbers in Grafana.

What I want is the # of Work Items Processed per minute.

Is my query wrong? or my Unit of Measure in my Y Axis. I currently have it as ops/min and its giving me a super small number.

Upvotes: 6

Views: 5639

Answers (2)

valyala
valyala

Reputation: 18010

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.

Upvotes: 0

Oliver
Oliver

Reputation: 13021

According to the documentation, rate(processed_work_items_total{job="MainWorker"}[1m]) will calculate the number of work items processed per second, measured over the last one minute (that's the [1m] from your query).

If you want the number of items per minute, simply multiply the above metric with 60.

Upvotes: 4

Related Questions