Flux stream and table functions

Use stream and table functions to extract a table from a stream of tables and access its columns and records.

Example stream and table functions

Recommended usage
  1. data = from(bucket:"example-bucket")
  2. |> range(start: -5m)
  3. |> filter(fn:(r) => r._measurement == "cpu")
  4. // Extract the "_value" column from the table
  5. data
  6. |> findColumn(fn: (key) => key._field == "usage_idle", column: "_value")
  7. // Extract the first record from the table
  8. data
  9. |> findRecord(fn: (key) => key._field == "usage_idle", idx: 0)
Alternate usage
  1. data = from(bucket:"example-bucket")
  2. |> range(start: -5m)
  3. |> filter(fn:(r) => r._measurement == "cpu")
  4. // Extract the first available table for which "_field" is equal to "usage_idle"
  5. t = data |> tableFind(fn: (key) => key._field == "usage_idle")
  6. // Extract the "_value" column from the table
  7. values = t |> getColumn(column: "_value")
  8. // Extract the first record from the table
  9. r0 = t |> getRecord(idx: 0)

Related articles

functions