Reputation: 385
is there a way to query prometheus and return 24hour snapshots of a metric over the course of a week?
Details about the metric:
The metric is scraped every minute and the value
will vary like so
I want to turn this into something that looks like
Which is taking a rollup of all the values within a 24hour period and creating a single sum'd value for each day.
Is this possible?
Thanks!
Upvotes: 0
Views: 2718
Reputation: 17800
This is possible with Prometheus subqueries. For example, the following query should return per-day averages for the metric
:
last_over_time(
avg_over_time(metric[1d])[1d:1d]
)
Note that the returned results will be shifted 1 day forward because Prometheus performs calculations over lookbehind windows in square brackets. This can be fixed by adding offset -1d
inside the query:
last_over_time(
avg_over_time(metric[1d] offset -1d)[1d:1d]
)
Unfortunately the given query with negative offset doesn't work in Prometheus older than v2.33.0. But this query works perfectly in all the versions of VictoriaMetrics - the Prometheus-like monitoring system I work on.
Upvotes: 2