Documentation

integral() function

The integral() function computes the area under the curve per unit of time of subsequent non-null records. The curve is defined using _time as the domain and record values as the range.

Function type: Aggregate
Output data type: Float

integral(
  unit: 10s,
  column: "_value",
  timeColumn: "_time",
  interpolation: ""
)

Parameters

unit

Time duration used when computing the integral.

Data type: Duration

column

Column on which to operate. Defaults to "_value".

Data type: String

timeColumn

Column that contains time values to use in the operation. Defaults to "_time".

Data type: String

interpolate

Type of interpolation to use. Defaults to "".

Use one of the following interpolation options:

  • empty sting for no interpolation
  • linear

Data type: String

Examples

Calculate the integral
from(bucket: "example-bucket")
  |> range(start: -5m)
  |> filter(fn: (r) =>
    r._measurement == "cpu" and
    r._field == "usage_system"
  )
  |> integral(unit:10s)
Calculate the integral with linear interpolation
from(bucket: "example-bucket")
  |> range(start: -5m)
  |> filter(fn: (r) =>
    r._measurement == "cpu" and
    r._field == "usage_system"
  )
  |> integral(unit:10s, interpolate: "linear")

New! Cloud or OSS?