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", 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()
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.