Calculates the average for a field over a set of events. The result is returned in a field named _avg. You can use this field name to pipe the results to other query functions for further processing, as shown in the example below.

ParameterTypeRequiredDefault ValueDescription
asstringoptional[a] _avg The optional name of the output field.
field[b]stringrequired   The field from which to extract a number and calculate the average.

[a] Optional parameters use their default value unless explicitly set.

[b] The parameter name field can be omitted.

Hide omitted argument names for this function

Show omitted argument names for this function

avg() Examples

Click + next to an example below to get the full details.

Calculate Average of Field Values in an Array

Calculate Average of Field Values in a flat array using the array:reduceRow() function

Calculate the Mean of CPU Time

Calculate the sum of all numbers (mean) of the CPU time

Compute Average Value for Each Array Element With Same Index

Compute an average value for each array element with the same index across multiple events using the array:reduceColumn()