experimental.alignTime() function

The experimental.alignTime() function is subject to change at any time. By using this function, you accept the risks of experimental functions.

The experimental.alignTime() function aligns input tables to a common start time.

*Function type: Transformation*

  1. import "experimental"
  2. experimental.alignTime(
  3. alignTo: 1970-01-01T00:00:00.000000000Z
  4. )

Parameters

alignTo

The UTC time to align tables to. Default is 1970-01-01T00:00:00Z.

*Data type: Time*

Examples

Compare values month-over-month

  1. import "experimental"
  2. from(bucket: "example-bucket")
  3. |> range(start: -12mo)
  4. |> filter(fn: (r) => r._measurement == "example-measurement")
  5. |> window(every: 1mo)
  6. |> experimental.alignTime()

Given the following input:

_time_value
2020-01-01T00:00:00Z32.1
2020-01-02T00:00:00Z32.9
2020-01-03T00:00:00Z33.2
2020-01-04T00:00:00Z34.0
2020-02-01T00:00:00Z38.3
2020-02-02T00:00:00Z38.4
2020-02-03T00:00:00Z37.8
2020-02-04T00:00:00Z37.5

The following functions:

  1. Window data by calendar month creating two separate tables (one for January and one for February).
  2. Align tables to 2020-01-01T00:00:00Z.

    1. //...
    2. |> window(every: 1mo)
    3. |> alignTime(alignTo: 2020-01-01T00:00:00Z)

And output:

_time_value
2020-01-01T00:00:00Z32.1
2020-01-02T00:00:00Z32.9
2020-01-03T00:00:00Z33.2
2020-01-04T00:00:00Z34.0
_time_value
2020-01-01T00:00:00Z38.3
2020-01-02T00:00:00Z38.4
2020-01-03T00:00:00Z37.8
2020-01-04T00:00:00Z37.5

Each output table represents data from a calendar month. When visualized, data is still grouped by month, but timestamps are aligned to a common start time and values can be compared by time.