Documentation

findRecord() function

The findRecord() function returns a record at a specified index from the first table in a stream of tables where the group key values match the specified predicate. The function returns an empty record if no table is found or if the index is out of bounds.

Function type: Stream and table

findRecord(
  fn: (key) => key._field == "fieldName",
  idx: 0
)

Parameters

fn

A predicate function for matching keys in a table’s group key. Expects a key argument that represents a group key in the input stream.

Data type: Function

idx

Index of the record to extract.

Data type: Integer

Example

r0 = from(bucket:"example-bucket")
    |> range(start: -5m)
    |> filter(fn:(r) => r._measurement == "cpu")
    |> tableFind()
    |> findRecord(
      fn: (key) => key._field == "usage_idle",
      idx: 0
    )

// Use record values
x = r0._field + "--" + r0._measurement

New! Cloud or OSS?

InfluxDB OSS 2.0 now generally available!

InfluxDB OSS 2.0 is now generally available and ready for production use. See the InfluxDB OSS 2.0 release notes.

For information about upgrading to InfluxDB OSS 2.0, see: