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.

GreNodge
  • 907
  • 4
  • 12
  • 26
  • Having the same issue and also no solution. It seems that for today this is not implemented yet. See: https://github.com/influxdata/flux/issues/406#issuecomment-667986195 for a basic workaround. But it wont work for daylight saving time. – maggie Feb 19 '21 at 10:20

2 Answers2

2

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")
Bertrand P
  • 820
  • 7
  • 24
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.

marcodb
  • 81
  • 1
  • 4