elapsed() function

The elapsed() function returns the time between subsequent records. Given an input table, elapsed() returns the same table without the first record (as elapsed time is not defined) and an additional column containing the elapsed time.

*Function type: Transformation*

  1. elapsed(
  2. unit: 1s,
  3. timeColumn: "_time",
  4. columnName: "elapsed"
  5. )

elapsed() returns an errors if the timeColumn is not present in the input table.

Parameters

unit

The unit time to returned. Defaults to 1s.

*Data type: Duration*

timeColumn

The column to use to compute the elapsed time. Defaults to "_time".

*Data type: String*

columnName

The column to store elapsed times. Defaults to "elapsed".

*Data type: String*

Examples

Calculate the time between points in seconds
  1. from(bucket: "example-bucket")
  2. |> range(start: -5m)
  3. |> elapsed(unit: 1s)

Related articles