avg
Description
Returns the average (mean) value of a numerical expression.
Note
The input must be a number. Use a cast if the field is stored as a string.
Syntax
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
| expression | number | true | Expression that evaluates to a number |
Example
Use case: Compute the average HTTP request latency per path
Suppose you want to calculate the average request duration for each URL path in your logs.
Example data
{ "path": "/home", "duration": 400 },
{ "path": "/home", "duration": 600 },
{ "path": "/login", "duration": 200 }
Example query
Example output
| path | average_duration_for_path |
|---|---|
| /home | 500 |
| /login | 200 |
Theme
Light