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

# ES|QL DERIV function
<applies-to>
  - Elastic Stack: Preview in 9.3
</applies-to>


## Syntax

![Embedded](https://www.elastic.co/docs/reference/query-languages/esql/images/functions/deriv.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 derivative over time
  </definition>
</definitions>


## Description

Calculates the derivative over time of a numeric field using linear regression.

## Supported types


| field   | window                                                                  | result |
|---------|-------------------------------------------------------------------------|--------|
| double  | 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 |


## Example

```esql
TS datenanos-k8s
| WHERE pod == "three"
| STATS max_deriv = MAX(DERIV(network.cost)) BY time_bucket = BUCKET(@timestamp,5minute), pod
```


| max_deriv:double | time_bucket:date_nanos   | pod:keyword |
|------------------|--------------------------|-------------|
| 0.101674         | 2024-05-10T00:00:00.000Z | three       |
| 0.0411           | 2024-05-10T00:05:00.000Z | three       |
| -0.017149        | 2024-05-10T00:10:00.000Z | three       |