Documentation

sample() function

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

Function type: Selector
Output data type: Record

sample(n:5, pos: -1)

Empty tables

sample() drops empty tables.

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:"example-bucket")
  |> range(start:-1d)
  |> filter(fn: (r) =>
    r._measurement == "cpu" and
    r._field == "usage_system"
  )
  |> sample(n: 5, pos: 1)

New! Cloud or OSS?

InfluxDB OSS 2.0 now generally available!

InfluxDB OSS 2.0 is now generally available and ready for production use. See the InfluxDB OSS 2.0 release notes.

For information about upgrading to InfluxDB OSS 2.0, see: