I have influxdb 1.8+ version and Grafana 9.2+ version on Windows machine PC.
Currently the computer is in Timezone GMT+4 and I have customized software that writes data to influxdb server at timestamp equal to the same timezone (GMT+4).
Now everything is working fine when querying data relative to time (last 5min, last 3 hours and etc), I experience some problem when querying last 7 days of data and groupby it on “24h” or “1d”. I found at that it calculates the aggregation based on Day1+4H to Day2+4h, instead of for example Mar 1 00:00:00 to Mar 1 23:59:59, it calculates to Mar 1 04:00:00 Mar 2 03:59:59, so basically it offset to my time region which is I don’t like.
Any idea how can I fix this?
Regards,
all data grafana uses should be in UTC in the source db. if not you will need to write a function that changes that datetime to UTC
1 Like
Hi @yosiasz thanks for the info.
Does this mean that my computer (where influxdb installed) should be in UTC timezone?
Because current setup is I installed it in machine where timezone is GMT+4. I don’t know if my understanding was right (correct me if I am wrong).
OR…
Should my customized software writing data in UTC timestamp? (regardless of my influxdb server timezone?). So in my case, the customized software should writing on -4 hours (UTC time) isn’t it?
Thanks and regards,
Please see my comment carefully
I mention only the db. Either the time on db date column has to be utc when writing to it or use a function that converts current non utc datetime column to utc
Hi @yosiasz apologies for I am literally confused .
Assuming the time in my db level is not in UTC (it is on GMT+4 timezone as per my current setup) is there a function in grafana that I can convert the time to UTC?
Should I change the timezone on my grafana to UTC? or should I add TZ(‘UTC’) on my influxdb query, thanks!
Again, All of it in the db. So is there a function in influxdb that changes non utc to utc?
Yes there is…
My grafana’s browser default timezone is in Dubai also (GMT+4).
And check the timestamp returned by grafana is already in GMT+0. I think working now. Thanks!
1 Like