sample() function

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

sample(n:5, pos: -1)

Empty tables

sample() drops empty tables.



(Required) Sample every Nth element.


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. Default is -1 (random offset).


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


The following example uses data provided by the sampledata package to show how sample() transforms data.

import "sampledata"
    |> sample(n: 2, pos: 1)

View input and output

Was this page helpful?

Thank you for your feedback!

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.