0

I want to get the maximum of a time series per day, so one data point each day at time 00:00:00. The maximum should be calculated over the range 00:00:00 until 23:59:59 for each day.

What i got so far:

SELECT max("temperature") FROM "Temperature" WHERE $timeFilter GROUP BY time(1d)

($timeFilter is used by Grafana for displaying only the selected time range) With that query i get the output data points at the wrong time.

EDIT: When i run

> precision rfc3339
> SELECT max("temperature") FROM "Temperature" WHERE time > now() - 7d GROUP BY time(1d) fill(null)

name: Temperature
time                 max
----                 ---
2020-03-22T00:00:00Z 4.5
2020-03-23T00:00:00Z 9.687
2020-03-24T00:00:00Z 10.75
2020-03-25T00:00:00Z 8.5
2020-03-26T00:00:00Z 11.062
2020-03-27T00:00:00Z 10.25
...

in the CLI, the timestamps seem right.

But in Grafana the data points are placed at 02:00 each day. misalignment

Thanks!

Marvin Noll
  • 585
  • 1
  • 7
  • 23

2 Answers2

2

Result from the InfluxDB is in the UTC. But Grafana interpolates timestamp to your browser timezone by default (so your browser/local environment reports your local timezone UTC+2). You can change this behavior in the dashboard configuration, for example you can keep timestamps in the UTC:

enter image description here

Jan Garaj
  • 25,598
  • 3
  • 38
  • 59
  • Good suggestion, didn't know that. But this messes with my other Panels in the same dashboard. Is there another way? – Marvin Noll Apr 21 '20 at 18:44
  • 1
    @MarvinNoll Maybe time zone clause in the query may help you (https://github.com/grafana/grafana/pull/14627) if you really want that on the panel level. But that is hackish and it may works only for one particular timezone. Slightly better approach can be dashboard in the UTC and other queries/panels with your local time zone clause. – Jan Garaj Apr 21 '20 at 19:18
1

I think i found a solution myself:

Click '+' next to GROUP BY and select tz(), then enter the desired time zone.

tz

Marvin Noll
  • 585
  • 1
  • 7
  • 23