aggregateWindow aligned to specified timezone
Asked Answered
C

2

6

Given the following query in Influxdb's Flux language:

from(bucket: "some-great-metrics")
   |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
   |> aggregateWindow(every: 1mo, fn: sum)
   |> yield() 

Assuming my current timezone is PST. How to ensure that aggregateWindow respect the beginning and end of the 1mo duration in this specific timezone (PST)?

Searching in the documentation does not bring so much light to me, so far.

Coalition answered 16/2, 2021 at 13:11 Comment(1)
Having the same issue and also no solution. It seems that for today this is not implemented yet. See: github.com/influxdata/flux/issues/406#issuecomment-667986195 for a basic workaround. But it wont work for daylight saving time.Dowery
G
3

Seems like Influx 2.1 comes with a new Flux timezone package

You can try to upgrade to 2.1 and add this before your query:

import "timezone"

option location = timezone.location(name: "America/Los_Angeles")
Gombosi answered 17/11, 2021 at 16:26 Comment(0)
R
1

Things are getting more and more interesting with Flux. Besides the option location that allows you to assign one time zone to an entire query (applicable to the original question, but not applicable in general), many functions that operate on time (including aggregateWindow()) now offer a location argument that allows you to operate with multiple time zones in a single streams of table. Unfortunately some of these are still undocumented.

In case, I've written an extensive review here.

Raymund answered 6/6, 2022 at 1:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.