toDuration() function

toDuration() was removed in Flux 0.37.

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

Function type: Type conversion


Supported data types: Integer | String | Uinteger

duration() assumes numeric input values are nanoseconds. String input values must use duration literal representation.

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


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

Function definition

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

Used functions: map(), duration()

Set your InfluxDB URL

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.