query.filterFields() function

The query.filterFields() function is experimental and subject to change at any time. By using this function, you accept the risks of experimental functions.

The query.filterFields() function filters input data by field.

Function type: Transformation

import "experimental/query"

query.filterFields(
  fields: ["exampleField1", "exampleField2"]
)

Parameters

fields

Fields to filter by. Must be exact string matches.

Data type: Array of strings

Examples

import "experimental/query"

query.fromRange(bucket: "telegraf/autogen", start: -1h)
  |> query.filterFields(
    fields: ["used_percent", "available_percent"]
  )

Function definition

package query

filterFields = (tables=<-, fields=[]) =>
  if length(arr: fields) == 0 then
    tables
  else
    tables
      |> filter(fn: (r) => contains(value: r._field, set: fields))

Used functions:
contains()
filter()
length()

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


Need help getting up and running? Get Support