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
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, the following resources are available:
InfluxDB Cloud and InfluxDB Enterprise customers can contact InfluxData Support.