InfluxDB Docs

aggregate.rate() function

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

The aggregate.rate() function calculates the rate of change per windows of time.

Function type: Transformation

import "experimental/query"

aggregate.rate(
  every: 1m,
  groupColumns: ["column1", "column2"],
  unit: 1s
)

Parameters

every

Duration of time windows.

Data type: Duration

groupColumns

List of columns to group by. Defaults to [].

Data type: Array of strings

unit

The time duration to use when calculating the rate. Defaults to 1s.

Data type: Duration

Examples

import "experimental/aggregate"

from(bucket: "example-bucket")
  |> range(start: -1h)
  |> aggregate.rate(every: 5m, unit: 1m)

Function definition

package aggregate

import "experimental"

rate = (tables=<-, every, groupColumns=[], unit=1s) =>
  tables
    |> derivative(nonNegative:true, unit:unit)
    |> aggregateWindow(every: every, fn : (tables=<-, column) =>
      tables
        |> mean(column: column)
        |> group(columns: groupColumns)
        |> experimental.group(columns: ["_start", "_stop"], mode:"extend")
        |> sum()
    )

Used functions:
aggregateWindow()
derivative()
experimental.group()
group()
mean()
sum()