Hi,
I’m using InfluxDB2 with Flux but that is probably also valid for previous versions.
When trying to get daily aggregated values, a day seams to be defined as a day in UTC time. But I’m in UTC+1 so I’m always getting the sums from 01:00 day1 to 01:00 of day2. Is there a way to change this behavior?
Hi @Anaisdg ,
thanks for your reply. Adjusting the range is not really an issue. My biggest concern is handling the aggregateWindow(every: 1d, fn:max).
In my case I have a datasource that accumulates daily values (energy generation in this example) that resets every day on 0:00 to zero. Unfortunately I have no control over this behavior and therefore can’t change it.
Currently the aggregateWindow messes up the data if I aggregate the daily max values if the aggregation window doesn’t match the reset window of the data source.
At the moment I’m working around this with |> timeShift(duration: -1h) but this is probably unreliable as I expect this to mess up the data as soon as we enter the daylight saving time again…
For what ever reason this was not problem with the according InfluxQL statement. Some magic took care of the timezones: SELECT max("some_value") FROM "some_measurement" WHERE $timeFilter GROUP BY time(1d) fill(null)
Also looking for a solution here. I want to run the aggregate function over set day windows. I tried setting the start time exactly to the start of the 24hour window I want to use but the timestamps returned still use UTC midnight as the time value.
Also don’t want to rely on time shifting if possible - doesn’t seem like the clean solution.
After hours of debugging, I’ve found that you have to add a “compensation” to the timezone on the aggregateWindow function using the offset parameter. Not straightforward, but seems to be working. You can try it out.
For an offset of GMT-03:00 you should add the difference, so:
aggregateWindow(every: 1d, fn: sum, offset: 3h)