Documentation

keep() function

Flux 0.7.0+

The keep() function returns a table containing only the specified columns, ignoring all others. Only columns in the group key that are also specified in the keep() function will be kept in the resulting group key. It is the inverse of drop.

keep(columns: ["col1", "col2"])

// OR

keep(fn: (column) => column =~ /inodes*/)

Parameters

Make sure fn parameter names match each specified parameter. To learn why, see Match parameter names.

columns

Columns that should be included in the resulting table. Cannot be used with fn.

fn

A predicate function which takes a column name as a parameter (column) and returns a boolean indicating whether or not the column should be included in the resulting table. Cannot be used with columns.

tables

Input data. Default is piped-forward data (<-).

Examples

The following examples use data provided by the sampledata package to show how keep() transforms data.

Keep a list of columns

import "sampledata"

sampledata.int()
  |> keep(columns: ["_time", "_value"])

View input and output

Keep columns matching a predicate

import "sampledata"

sampledata.int()
  |> keep(fn: (column) => column =~ /^_?t/)

View input and output


Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.