getRecord() function

The getRecord() function extracts a record from a table given the record’s index. If the index is out of bounds, the function errors.

*Function type: Stream and table*

  1. getRecord(idx: 0)

Use tableFind() to extract a single table

getRecord() requires a single table as input. Use tableFind() to extract a single table from a stream of tables.

Parameters

idx

Index of the record to extract.

*Data type: Integer*

Example

  1. r0 = from(bucket:"example-bucket")
  2. |> range(start: -5m)
  3. |> filter(fn:(r) => r._measurement == "cpu")
  4. |> tableFind(fn: (key) => key._field == "usage_idle")
  5. |> getRecord(idx: 0)
  6. // Use record values
  7. x = r0._field + "--" + r0._measurement

Related articles