Samples the event stream. Events that do not have the field being sampled are discarded.

Function Traits: Filter

ParameterTypeRequiredDefaultDescription
fieldstringoptional@timestamp The names of the field to use for sampling events.
percentage[a]numberoptional1 Keep this percentage of the events.
  Maximum100 
  Valid Values1

[a] The argument name percentage can be omitted.

The parameter name for percentage can be omitted; the following forms are equivalent:

logscale
sample("1")

and:

logscale
sample(percentage="1")

sample() Examples

Sample events keeping only 2% of the events

logscale
sample(percentage=2)

Sample events keeping only 0.1% of the events to allow groupby to find the most common hosts without hitting the groupby-limit:

logscale
sample(percentage=0.1)
| groupby(host)
| sort()