Query from InfluxDB is one hour in the future

Hey everyone,

Grafana works like a charm, but the timezone issue is very tedious and I wasted already three hours for nothing. At this point I am just annoyed, because I am not the only one having this issue, but it seems that Grafana has no interest in guiding the user more in this topic.

The problem is that I cannot get the time scale on the plot and the plotted data inline. Always one of them is mismatched.

The setup is as follows, with a time as an example:
Remote Raspberry Pi with InfluxDB set on CET=UTC+1 (17:30:00)
Host Laptop is also set on CET=UTC+1 (17:30:00)

Timezone in Grafana under preference is UTC
Timezone in Grafana dashboard is UTC

Query is

SELECT “cpu_temp” FROM “cpu_temp” WHERE time >= now() - 1h

First Problem
When I click on the

Plot → Inspect → Data

I get data from 16:30:00 to 18:30:00. This is already confusing, because I expect data between 16:30:00 and 17:30:00. Why do we go into the future?

But super weird for me is, when I go to

Plot → Explore

and put in the same query I get data between 16:30:00 and 17:30:00 as expected, but the plot is one hour in the past. When I change timezone in Grafana under preference to Europe/Berlin (CET) I again get data from the future.
As you can see in the image the singlestat gives the correct value because it takes the last entry, which is in this case at 18:57:00, but the chart just goes to 17:58:00. When I change to Europe/Kiev (UTC+2) it is showing all the data, but its one hour in the future. The singlestat and the most recent value in the plot do not show the same value as well.

Second Problem
Timezone in Grafana under preference is Europe/Berlin
Timezone in Grafana dashboard is Europe/Berlin

But in the dashboard on the right top where the time is, I see next to the time in orange CET and when I click on it to change for example to “Last 1 Hour” I see in orange Europe/Berlin on the bottom of the drop down menu (see image).

So the question is, how can I make Grafana retrieved the right data from the InfluxDB and also plot it correctly.

I hope that I explained my problem good enough and feel free to comment.
Thanks.

Hi, I had similar issue.

Problem is probably that you write data to InfluxDB in wrong timezone.

When you write data to InfluxDB it automaticaly stores in UTC (+0) timezone. If you import let’s say data which is in +1, you should convert to UTC before storing data, that means you should substract one hour so you would get UTC time.

Then in Grafana dashboard you can choose default timezone which in this case would be +1 and it shows data correctly!

Also notice if living in a country that changes timezone, +1 for half year and +2 for other half year, then import to InfluxDB should be altered accordingly to get UTC time.

Hope this helps.

Thanks for the tip.

So the solution for me was to convert the time from UTC+1 to UTC before writing the data into the influx database, like edin008 suggested. This will create some more work, because of the hopefully soon canceled summer/winter time Europe, but now the plot likes as I expect to look like :).

1 Like