---
title: ES|QL AVG_OVER_TIME function
description: 
url: https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/time-series-aggregation-functions/avg_over_time
products:
  - Elasticsearch
---

# ES|QL AVG_OVER_TIME function
<applies-to>
  - Elastic Stack: Preview from 9.2 to 9.3
</applies-to>


## Syntax

![Embedded](https://www.elastic.co/docs/reference/query-languages/esql/images/functions/avg_over_time.svg)


## Parameters

<definitions>
  <definition term="field">
    the metric field to calculate the value for
  </definition>
  <definition term="window">
    the time window over which to compute the average
  </definition>
</definitions>


## Description

Calculates the average over time of a numeric field.

## Supported types


| field                                                                        | window                                                                  | result |
|------------------------------------------------------------------------------|-------------------------------------------------------------------------|--------|
| aggregate_metric_double                                                      | time_duration <applies-to>Elastic Stack: Preview since 9.3</applies-to> | double |
| double                                                                       | time_duration <applies-to>Elastic Stack: Preview since 9.3</applies-to> | double |
| exponential_histogram <applies-to>Elastic Stack: Preview in 9.3</applies-to> | time_duration <applies-to>Elastic Stack: Preview since 9.3</applies-to> | double |
| integer                                                                      | time_duration <applies-to>Elastic Stack: Preview since 9.3</applies-to> | double |
| long                                                                         | time_duration <applies-to>Elastic Stack: Preview since 9.3</applies-to> | double |
| tdigest <applies-to>Elastic Stack: Preview in 9.3</applies-to>               | time_duration <applies-to>Elastic Stack: Preview since 9.3</applies-to> | double |


## Example

```esql
TS k8s
| STATS max_cost=MAX(AVG_OVER_TIME(network.cost)) BY cluster, time_bucket = TBUCKET(1minute)
```


| max_cost:double | cluster:keyword | time_bucket:datetime     |
|-----------------|-----------------|--------------------------|
| 12.375          | prod            | 2024-05-10T00:17:00.000Z |
| 12.375          | qa              | 2024-05-10T00:01:00.000Z |
| 12.25           | prod            | 2024-05-10T00:19:00.000Z |
| 12.0625         | qa              | 2024-05-10T00:06:00.000Z |