filter() function

The filter() function filters data based on conditions defined in a predicate function (fn). The output tables have the same schema as the corresponding input tables.

Function type: Transformation
Output data type: Object

filter(fn: (r) => r._measurement == "cpu")

Parameters

fn

A single argument function that evaluates true or false. Records are passed to the function. Those that evaluate to true are included in the output tables.

Data type: Function

Objects evaluated in fn functions are represented by r, short for “record” or “row”.

Examples

from(bucket:"telegraf/autogen")
  |> range(start:-1h)
  |> filter(fn: (r) =>
    r._measurement == "cpu" AND
    r._field == "usage_system" AND
    r.cpu == "cpu-total"
  )

SELECT

This documentation is open source. See a typo? Please, open an issue.


Need help getting up and running? Get Support