Documentation

tickscript.selectWindow() function

Flux 0.111.0+

The tickscript.selectWindow() function is a user-contributed function maintained by the package author and can be updated or removed at any time.

The tickscript.selectWindow() function changes a column’s name, windows rows by time, and applies an aggregate or selector function the specified column for each window of time.

import "contrib/bonitoo-io/tickscript"

tickscript.selectWindow(
  column: "_value",
  fn: sum,
  as: "example-name",
  every: 1m,
  defaultValue: 0.0,
)

TICKscript helper function

tickscript.selectWindow() is a helper function meant to replicate TICKscript operations like the following:

// Rename, window, and aggregate
query("SELECT f(x) AS y")
  .groupBy(time(t), ...)

Parameters

column

Column to operate on. Default is _value.

Data type: String

fn

(Required) Aggregate or selector function to apply.

as

(Required) New column name.

every

(Required) Duration of windows.

defaultValue

(Required) Default fill value for null values in column.

Must be the same data type as column.

tables

Input data. Default is piped-forward data (<-).

Examples

Change the name of, window, and then aggregate the value column

import "contrib/bonitoo-io/tickscript"

data
  |> tickscript.selectWindow(
    fn: sum,
    as: "example-name",
    every: 1h,
    defaultValue: 0.0
  )
Input data
_time _value
2021-01-01T00:00:00Z 1.2
2021-01-01T00:30:00Z 0.8
2021-01-01T01:00:00Z 3.2
2021-01-01T01:30:00Z 3.9
2021-01-01T02:00:00Z
2021-01-01T02:30:00Z 3.3
Output data
_time example-name
2021-01-01T00:59:59 2.0
2021-01-01T01:59:59 7.1
2021-01-01T02:59:59 3.3

Package author and maintainer

Github: @bonitoo-io, @alespour
InfluxDB Slack: @Ales Pour


Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.