I have a need to prepare weekly stats on some of our metrics. Like for example weekly average memory usage or maximum weekly CPU %, or similar.
Further, I want this sliced on weeks starting on Monday and ending on Sunday.
I do an aggregation like this:
I then set the range in Grafana to show me last two weeks:
It properly shows the date range. At this specific timestamp of Friday, 9-Oct, it displays a range from 2020-09-20T22:00:00Z to 2020-10-04T21:59:00Z
Then I punch the query into Grafana.
If I click the Prometheus link I get proper query for Prometheus:
Range: 2 weeks x 7 days / week x 24 h / day x 60 min / h x 60 s / min = 1209600s. All good!
Step: 1 week x 7 days / week x 24 h / day x 60 min / h x 60 s / min = 604800. All good!
It’s now in UTC, and looks good. UI confirms it as well. See below.
Data fetched also looks good, with three data points, on the the beginning, one at the end and one in the middle (it’s two week range):
But if I inspect Grafana query, it is wrong:
1600293600 translates into 2020-09-16T22:00:00Z, so I got a shift back for 4 days.
The calendar range is right, the query was wrong and correspondingly wrong results were fetched and plotted:
So, how do I get rid of this time shit getting into query for Prometheus?