Docs

v2.0

sample() function

The sample() function selects a subset of the records from the input table.

Function type: Selector
Output data type: Object

sample(n:5, pos: -1)

Parameters

n

Sample every Nth element.

Data type: Integer

pos

The position offset from the start of results where sampling begins. pos must be less than n. If pos is less than 0, a random offset is used. Defaults to -1 (random offset).

Data type: Integer

Examples

from(bucket:"telegraf/autogen")
  |> range(start:-1d)
  |> filter(fn: (r) =>
    r._measurement == "cpu" and
    r._field == "usage_system"
  )
  |> sample(n: 5, pos: 1)

SAMPLE()


Bug Reports and Feedback

Thank you for being willing to help test InfluxDB v2.0 alpha! Feedback and bug reports are welcome and encouraged both for InfluxDB and this documentation.

Submit feedback in the InfluxData Community