Biswajit
Biswajit

Reputation: 169

Prometheus query to get the value of a metric since midnight or a dynamic offset

I am exporting a gauge metric named order_count to Prometheus and updating its value every 2 mins. I want to plot a Grafana graph about how many orders have been received since midnight of the same day. I know the offset can be calculated by time() % 86400 as in the number of seconds since midnight but prometheus does not accept dynamic offset values as follows

order_count - order_count offset (time() % 86400)s

How could I achieve the same. ? Any help would be greatly appreciated.

Upvotes: 5

Views: 1591

Answers (1)

Golda Velez
Golda Velez

Reputation: 199

in your case you can do this with start() and using a time range of "today so far" for the time range of the graph

However there are a lot of other cases where calculating the offset would be extremely helpful - my team wants to have daily counts for "total past day" over a 7 day period and I am tearing my hair out trying to get it to offset always on the day, not relative to the current time.

Please allow calculations in offset!

Upvotes: 1

Related Questions