Error while defining location parameter for aggregateWindow

Hi all,

When I try to set location parameter in aggregateWindow parameters as below:

  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false, location: "UTC")

I get an error like:

 error @5:6-5:91: expected {zone:string, offset:duration} but found string (argument location)

Can you help me with that?

Thank you,

Muti

Hello,

I think you can’t use “mean” for a string.
Try “distinct” instead.
Did you tried Chronograf ?

Regards,

Location parameter is of record type, with zone and offset fields, not just zone name string. Please have a look at timezone package. This should work:

import "timezone"
...
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false, location: timezone.utc)

I think something wrong with my setup. When I execute the query below:

import "timezone"

timezone.location(name: "America/Los_Angeles")

I get an error like:

 error calling function "location" @3:1-3:47: unknown time zone America/Los_Angeles

Any kind of help is much appreciated!

Thank you,

Muti

I extended my example to the below one, and it still gives an error. Can you please suggest a solution?

Query: I want to aggregate my data which represented in utc time for days in America/Los_Angeles timezone. aggregateWindow 's location parameter is throwing an error when added to the query.

import "array"
import "timezone"

// _time is utc - they have the Z suffix in the litteral
data = array.from(rows:[ 
    {_time: 2022-03-12T00:00:00Z, _value: 10}
  , {_time: 2022-03-12T06:00:00Z, _value: 20}
  , {_time: 2022-03-12T12:00:00Z, _value: 30}
  , {_time: 2022-03-12T18:00:00Z, _value: 40}

  , {_time: 2022-03-13T00:00:00Z, _value: 100}
  , {_time: 2022-03-13T06:00:00Z, _value: 200}
  , {_time: 2022-03-13T12:00:00Z, _value: 300}
  , {_time: 2022-03-13T18:00:00Z, _value: 400}

  , {_time: 2022-03-14T00:00:00Z, _value: 1000}
  , {_time: 2022-03-14T06:00:00Z, _value: 2000}
  , {_time: 2022-03-14T12:00:00Z, _value: 3000}
  , {_time: 2022-03-14T18:00:00Z, _value: 4000} 
])
  |> range(start: 2022-03-12, stop: 2022-03-15)


// aggregate daily in "America/Los_Angeles" timezone
data
  |> range(start: 2022-03-11T00:00:00Z, stop: 2022-03-16T00:00:00Z)
  |> aggregateWindow( every: 1d
                    , fn:mean
                    , createEmpty: false
                    , location: timezone.location(name: "America/Los_Angeles")
                    )
  |> keep(columns: ["_time", "_value"])

error:

 error calling function "location" @30:33-30:79: unknown time zone America/Los_Angeles

It works for me with 2.1.1 docker image. It seems like your system is missing zone info files, at least the one for America/Los_Angeles.

How can I fix this on a windows machine?

Download Go’s zoneinfo.zip and set environment variable ZONEINFO with absolute path of the file, like

set ZONEINFO=C:\Data\zoneinfo.zip
influxd run

I’ve created issue #23248. It, or similar issue, was reported before and fixed. But I just tested 2.1.1 on Win7 machine and reproduced the error.