Prometheus query per day not in 24h "buckets"

Viewed 1302

I have a prometheus instance with grafana as UI and I want to have a graph that sums a rate of a gauge.

Right now I have something like:

sum(rate(myNiceMetric[1d])*60*60*24) by (result,component)

But the problem is that the rate time window covers the last 24h, but to have stable numbers I need it to be by day (00:00-24:00)

Is there a way to achieve that?

1 Answers

You can use the time range of the dashboard:

sum(rate(myNiceMetric[$__range])*$__range_s) by (result,component)

The panel will adjust automatically to the chosen time range (ex: last 24 hours, Yesterday, Today so far, Previous week, etc).

More info in the Grafana documentation here.

Related