Documentation

v1.fieldsAsCols() function

Flux 0.16.0 – 0.88.0

v1.fieldsAsCols() was deprecated in Flux v0.88.0 in favor of schema.fieldsAsCols().

The v1.fieldsAsCols() function is a special application of the pivot() function that pivots on _field and _time columns to aligns fields within each input table that have the same timestamp. and resemble InfluxDB 1.x query output.

import "influxdata/influxdb/v1"

v1.fieldsAsCols()

Parameters

tables

Input data. Default is piped-forward data (<-).

Examples

import "influxdata/influxdb/v1"

from(bucket:"example-bucket")
  |> range(start: -1h)
  |> filter(fn: (r) => r._measurement == "cpu")
  |> v1.fieldsAsCols()

View example input and output

Function definition

package v1

fieldsAsCols = (tables=<-) =>
  tables
    |> pivot(
      rowKey:["_time"],
      columnKey: ["_field"],
      valueColumn: "_value"
    )

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.