Different result using Flux aggregateWindow() with timezone (standalone/cloud)

I am using both InfluxDB v2.7.11 (windows) and InfluxDB Cloud 2 (on us-east-1-1.aws.cloud2.influxdata.com).
Having same data in both of them.

BUT querying data with aggregateWindow() and timezone gives me different results:

  • aggregateWindow() WITHOUT timezone gives me same result on standalone and cloud (localhost.PNG, cloud.PNG)
  • aggregateWindow() WITH timezone gives me different result on standalone and cloud (localhost_tz.PNG, cloud_tz.PNG)
import "timezone"

//comment to omit timezone support in aggregateWindow()
option location = timezone.location(name: "Europe/Vienna")
 
from(bucket: "nibe")
  |> range(start: 2024-12-30T00:00:00Z, stop: 2025-01-02T23:59:59Z)
  |> filter(fn: (r) => r["_measurement"] == "total_act" and r["_field"] == "value")
  |> map(fn: (r) => ({ r with _value: r._value / 1000.0 }))
  |> aggregateWindow(every: 1d, fn: spread, timeSrc: "_start", createEmpty: true)

BTW: using InfluxDB v2.7.11 on Linux (tested via VirtualBox, Docker in IOTStack) behaves correctly - maybe a local issue in windows or a BUG in InfluxDB for windows ?

The difference in results when using aggregateWindow() with and without a timezone in InfluxDB (standalone vs. cloud) is likely due to how time zone handling is implemented across the two environments. This can be influenced by time zone settings, the server’s default time zone, or even differences in how the data is processed and stored between the standalone (local) and cloud instances of InfluxDB.

When you use aggregateWindow() without the timezone option, it relies on the default UTC time, which may behave consistently across both environments (standalone and cloud). However, when you include timezone.location(), the aggregation window is adjusted to the specified time zone (in your case, “Europe/Vienna”), and this can lead to different results based on how the standalone instance and cloud instance are handling time zone conversions.

Here are a few factors that might cause this difference:

Time Zone Configuration Differences: The standalone InfluxDB on Windows and InfluxDB Cloud may have different default time zone configurations, or the way time zone data is applied to the aggregation might differ. You might want to verify that both environments are set to use the same time zone handling mechanism.

Time Zone Conversion Impact: The aggregateWindow() function calculates windows of data based on the timestamps, and when you specify a time zone, it adjusts the data accordingly. Differences in how the cloud instance and the standalone instance handle daylight saving time or time zone offsets could lead to discrepancies in results, especially when the aggregation spans across time zones or daylight saving time changes.

Data Ingestion and Timestamp Precision: If data is ingested with slightly different timestamps or there are any microseconds or rounding differences, this could affect how the aggregation is applied, especially when using time zone adjustments. Ensure that the timestamps in both instances are identical down to the level of precision required by your aggregation logic.

Timezone-Specific Handling in Cloud: InfluxDB Cloud might be handling the timezone differently, especially in terms of how it applies the aggregateWindow() function to your data. This could be affected by server-side optimizations or how cloud services handle time zone data for processing.

Recommendations:
Consistency Between Standalone and Cloud: Make sure both InfluxDB instances (standalone and cloud) are running the same version and have consistent time zone settings. Verify that the timezone.location(name: “Europe/Vienna”) is correctly applied in both environments.

Use tz() Function for Debugging: You can add the tz() function in your query to check how the time zone is applied across the different instances:

from(bucket: “nibe”)
|> range(start: 2024-12-30T00:00:00Z, stop: 2025-01-02T23:59:59Z)
|> filter(fn: (r) => r[“_measurement”] == “total_act” and r[“_field”] == “value”)
|> map(fn: (r) => ({ r with _value: r._value / 1000.0 }))
|> tz(offset: 0h) // Adjust if necessary for your local time zone
|> aggregateWindow(every: 1d, fn: spread, timeSrc: “_start”, createEmpty: true)

Cross-check Time Zones in Both Instances: Test if the same query with the same data but without time zone adjustments in both environments produces identical results.

By exploring these aspects, software development experts https://tech-stack.com/ in the InfluxDB ecosystem often find that maintaining a consistent understanding of time zone settings and how they interact with aggregation functions is key to ensuring predictable results across environments.

Hi Slaughterhaus !

Thank you for your detailed explanation !

Both Standalone and Cloud have the same data and consistent time zone settings. The interesting thing is that exactly 1 value does not fit (see screenshot from 2024-12-31 → 2025-01-01 → change of year).

In the meantime I have set up 2 other standalone instances (raspberry, windows VM virtual box) running a linux system, imported the data and the aggregateWindow() with timezone shows the expected/correct result.

Cross-checked Time Zones in Both Instances (Test if the same query with the same data but without time zone adjustments in both environments produces identical results): They produce IDENTICAL results (UTC).

BTW i have additional data from 2023-12-31 → 2024-01-01 → change of year and there is no issue…

I think I will give up the windows version and only work under linux.

Does this perhaps have something to do with a (faulty) leap time handling on windows (2024 is a leap year), same issue also with leap year 2020 … ?

created a small FLUX script to reproduce:

import "array"
import "timezone"

array.from(rows:[ 
    {_time: 2024-12-30T00:00:00Z, _value: 10},
    {_time: 2024-12-31T00:00:00Z, _value: 20},
    {_time: 2025-01-01T00:00:00Z, _value: 30},
    {_time: 2025-01-02T00:00:00Z, _value: 40}
])
  |> range(start: 2024-12-29T00:00:00Z, stop: 2025-01-03T00:00:00Z)
  |> aggregateWindow(every: 1d, fn:sum, location: timezone.location(name: "Europe/Vienna"))

LINUX (2024-2025) - OK

tbl	val	_start						_stop						_time
0		2024-12-29T00:00:00.000Z	2025-01-03T00:00:00.000Z	2024-12-29T23:00:00.000Z
0	10	2024-12-29T00:00:00.000Z	2025-01-03T00:00:00.000Z	2024-12-30T23:00:00.000Z
0	20	2024-12-29T00:00:00.000Z	2025-01-03T00:00:00.000Z	2024-12-31T23:00:00.000Z
0	30	2024-12-29T00:00:00.000Z	2025-01-03T00:00:00.000Z	2025-01-01T23:00:00.000Z
0	40	2024-12-29T00:00:00.000Z	2025-01-03T00:00:00.000Z	2025-01-02T23:00:00.000Z
0		2024-12-29T00:00:00.000Z	2025-01-03T00:00:00.000Z	2025-01-03T00:00:00.000Z

WINDOWS (2024-2025) - NOK

tbl	val	_start						_stop						_time
0		2024-12-29T00:00:00.000Z	2025-01-03T00:00:00.000Z	2024-12-29T23:00:00.000Z
0	10	2024-12-29T00:00:00.000Z	2025-01-03T00:00:00.000Z	2024-12-30T23:00:00.000Z
0		2024-12-29T00:00:00.000Z	2025-01-03T00:00:00.000Z	2024-12-31T00:00:00.000Z
0	50	2024-12-29T00:00:00.000Z	2025-01-03T00:00:00.000Z	2025-01-01T23:00:00.000Z
0	40	2024-12-29T00:00:00.000Z	2025-01-03T00:00:00.000Z	2025-01-02T23:00:00.000Z
0		2024-12-29T00:00:00.000Z	2025-01-03T00:00:00.000Z	2025-01-03T00:00:00.000Z

WINDOWS (2023-2024) - OK

tbl	val	_start						_stop						_time
0		2023-12-29T00:00:00.000Z	2024-01-03T00:00:00.000Z	2023-12-29T23:00:00.000Z
0	10	2023-12-29T00:00:00.000Z	2024-01-03T00:00:00.000Z	2023-12-30T23:00:00.000Z
0	20	2023-12-29T00:00:00.000Z	2024-01-03T00:00:00.000Z	2023-12-31T23:00:00.000Z
0	30	2023-12-29T00:00:00.000Z	2024-01-03T00:00:00.000Z	2024-01-01T23:00:00.000Z
0	40	2023-12-29T00:00:00.000Z	2024-01-03T00:00:00.000Z	2024-01-02T23:00:00.000Z
0		2023-12-29T00:00:00.000Z	2024-01-03T00:00:00.000Z	2024-01-03T00:00:00.000Z

WINDOWS (2025-2026) - OK

tbl	val	_start						_stop						_time
0		2025-12-29T00:00:00.000Z	2026-01-03T00:00:00.000Z	2025-12-29T23:00:00.000Z
0	10	2025-12-29T00:00:00.000Z	2026-01-03T00:00:00.000Z	2025-12-30T23:00:00.000Z
0	20	2025-12-29T00:00:00.000Z	2026-01-03T00:00:00.000Z	2025-12-31T23:00:00.000Z
0	30	2025-12-29T00:00:00.000Z	2026-01-03T00:00:00.000Z	2026-01-01T23:00:00.000Z
0	40	2025-12-29T00:00:00.000Z	2026-01-03T00:00:00.000Z	2026-01-02T23:00:00.000Z
0		2025-12-29T00:00:00.000Z	2026-01-03T00:00:00.000Z	2026-01-03T00:00:00.000Z