Docs

toDuration() function

The toDuration() function converts all values in the _value column to durations.

Function type: Type conversion
Output data type: Duration

toDuration()

To convert values in a column other than _value, define a custom function patterned after the function definition, but replace the column in the duration() function with your desired column.

Examples

from(bucket: "telegraf")
  |> filter(fn:(r) =>
    r._measurement == "mem" and
    r._field == "used"
  )
  |> toDuration()

Function definition

toDuration = (tables=<-) =>
  tables
    |> map(fn:(r) => duration(v: r._value))

Used functions: map(), duration()