bottom() function

The bottom() function sorts a table by columns and keeps only the bottom n records.

Function type: Selector
Output data type: Object

bottom(n:10, columns: ["_value"])

Parameters

n

Number of records to return.

Data type: Integer

columns

List of columns by which to sort. Sort precedence is determined by list order (left to right). Default is ["_value"].

Data type: Array of strings

Examples

from(bucket:"telegraf/autogen")
  |> range(start:-1h)
  |> filter(fn: (r) =>
    r._measurement == "mem" AND
    r._field == "used_percent"
  )
  |> bottom(n:10)

Function definition

// _sortLimit is a helper function, which sorts and limits a table.
_sortLimit = (n, desc, columns=["_value"], tables=<-) =>
  tables
    |> sort(columns:columns, desc:desc)
    |> limit(n:n)

bottom = (n, columns=["_value"], tables=<-) =>
  _sortLimit(n:n, columns:columns, desc:false)

BOTTOM()

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


Need help getting up and running? Get Support