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

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


## Syntax

![Embedded](https://www.elastic.co/elastic/docs-builder/docs/2987/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  |        | double |
| integer |        | double |
| long    |        | 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       |