Join the upcoming Developer Hackathon: Splunk Build-a-thon!Register now

 random()

On this page

Retrieves values at random from MTS in the input stream, based on a count or percentage.

 Syntax

random([count=c][, percentage=pct][, by=grp])

 Parameter definitions

ParameterTypeDescription
countinteger. Default is None.Optional: Number of values to pass through to the output stream. Mutually exclusive with percentage.
percentageDouble,0.0 < percentage ≤ 1.0
Default is None.
Optional: Percent of values to pass through to the output stream. Mutually exclusive with count.
bystring or list of strings. Default is None.Optional: Names of properties to group the output by

Returns a stream

 Examples

#Return 5 random cpu utilization values
data('cpu.utilization').random(5)

#Return a random 5 percent of cpu utilization, grouped by 'env'
data('cpu.utilization').random(percentage=.05, by='env')

#Return 10 random cpu utilization values grouped by env and datacenter
data('cpu.utilization').random(10, by=['env', 'datacenter'])