avg()
Calculates the average of all expressions that belong to the group. It eliminates expression which returns null or a non-numeric value.
Syntax
avg(NUM_EXPR)
Required parameter
NUM_EXPR
- Numeric expression
Usage
# Create 2 fields with 100 random records with numbers in the range of 1 to 100 and calculate the average.
| json "{}"
| repeat count=100 | eval n1=rand(101), n2=rand(101)
| stats avg(n1) as n1_avg, avg(n2) as n2_avg