v1.fieldsAsCols() function

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.

*Function type: Transformation*

  1. import "influxdata/influxdb/v1"
  2. v1.fieldsAsCols()

Examples

  1. import "influxdata/influxdb/v1"
  2. from(bucket:"example-bucket")
  3. |> range(start: -1h)
  4. |> filter(fn: (r) => r._measurement == "cpu")
  5. |> v1.fieldsAsCols()
  6. |> keep(columns: ["_time", "cpu", "usage_idle", "usage_user"])

Function definition

  1. package v1
  2. fieldsAsCols = (tables=<-) =>
  3. tables
  4. |> pivot(
  5. rowKey:["_time"],
  6. columnKey: ["_field"],
  7. valueColumn: "_value"
  8. )

*Used functions: pivot()*