3.9 KiB
3.9 KiB
title | description | menu | weight | flux/v0.x/tags | introduced | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
experimental.alignTime() function | `experimental.alignTime()` shifts time values in input tables to all start at a common start time. |
|
101 |
|
0.66.0 |
experimental.alignTime()
shifts time values in input tables to all start at a common start time.
Function type signature
(<-tables: stream[B], ?alignTo: A) => stream[C] where B: Record, C: Record
{{% caption %}}For more information, see Function type signatures.{{% /caption %}}
Parameters
alignTo
Time to align tables to. Default is 1970-01-01T00:00:00Z
.
tables
Input data. Default is piped-forward data (<-
).
Examples
Compare month-over-month values
- Window data by calendar month creating two separate tables (one for January and one for February).
- Align tables to
2021-01-01T00:00:00Z
.
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.
import "experimental"
data
|> window(every: 1mo)
|> experimental.alignTime(alignTo: 2021-01-01T00:00:00Z)
{{< expand-wrapper >}} {{% expand "View example input and ouput" %}}
Input data
*_start | *_stop | _time | _value |
---|---|---|---|
2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-01T00:00:00Z | 32.1 |
2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-02T00:00:00Z | 32.9 |
2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-03T00:00:00Z | 33.2 |
2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-04T00:00:00Z | 34 |
2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-01T00:00:00Z | 38.3 |
2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-02T00:00:00Z | 38.4 |
2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-03T00:00:00Z | 37.8 |
2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-04T00:00:00Z | 37.5 |
Output data
*_start | *_stop | _time | _value |
---|---|---|---|
2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-01T00:00:00Z | 32.1 |
2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-02T00:00:00Z | 32.9 |
2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-03T00:00:00Z | 33.2 |
2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-04T00:00:00Z | 34 |
*_start | *_stop | _time | _value |
---|---|---|---|
2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-01T00:00:00Z | 38.3 |
2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-02T00:00:00Z | 38.4 |
2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-03T00:00:00Z | 37.8 |
2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-04T00:00:00Z | 37.5 |
{{% /expand %}} {{< /expand-wrapper >}}