SMA
SMA

Reputation: 377

Prometheus query to get just latest data for every day, (Max timestamp every day)

I have a PromQL query that returns data for past n days with interval of 10 minutes, is there any way I create a report that contains just n entry and each entry is the last value of the day? my current query is like: sum(increase(mymetric[1d])) the output data is like:

"Time","sum(increase(mymetric[1d]))"
2022-02-22 15:00:00,89637
2022-02-22 15:10:00,89715
2022-02-22 15:20:00,89711
2022-02-22 15:30:00,89751
2022-02-22 15:40:00,89737
2022-02-22 15:50:00,89774
2022-02-22 16:00:00,89811
...
...

2022-03-22 15:00:00,89671

What I need is an output like:

2022-02-22 00:00:00,89637
2022-02-23 00:00:00,89715
2022-02-24 00:00:00,89711
2022-02-25 00:00:00,89751
...
2022-03-22 00:00:00,89737

p.s. This query is something like a counter,

Upvotes: 2

Views: 3045

Answers (2)

Krzysztof Madejski
Krzysztof Madejski

Reputation: 7988

I'd use max_over_time(metric{}[24h]) but I'm not sure how to align it with the beginning of the day (or some other time of the day)

Upvotes: 0

SMA
SMA

Reputation: 377

Found the solution, I'm using Grafana for reporting, In Grafana I defined Min Step to 1d and the final report is what I wanted.

Upvotes: 3

Related Questions