﻿---
title: Aggregation functions
description: PromQL aggregation functions in Elasticsearch that aggregate instant vectors across series.
url: https://www.elastic.co/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/aggregation
products:
  - Elasticsearch
applies_to:
  - Elastic Cloud Serverless: Generally available
  - Elastic Stack: Preview in 9.4
---

# Aggregation functions
These functions aggregate the values of an instant vector across series, optionally grouped with `by` or `without`.

## `avg`

<applies-to>Elastic Stack: Preview in 9.4</applies-to>
Calculates the average of the values across the input vector.
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="v (instant_vector)">
    Instant vector input.
  </definition>
</definitions>

**Example**
```
avg(http_requests_total)
```


## `count`

<applies-to>Elastic Stack: Preview in 9.4</applies-to>
Counts the number of elements in the input vector.
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="v (instant_vector)">
    Instant vector input.
  </definition>
</definitions>

**Example**
```
count(http_requests_total)
```

**Differences from Prometheus**
Returns a `long` integer count rather than a floating-point value.

## `max`

<applies-to>Elastic Stack: Preview in 9.4</applies-to>
Returns the maximum value across the input vector.
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="v (instant_vector)">
    Instant vector input.
  </definition>
</definitions>

**Example**
```
max(http_requests_total)
```


## `min`

<applies-to>Elastic Stack: Preview in 9.4</applies-to>
Returns the minimum value across the input vector.
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="v (instant_vector)">
    Instant vector input.
  </definition>
</definitions>

**Example**
```
min(http_requests_total)
```


## `quantile`

<applies-to>Elastic Stack: Preview in 9.4</applies-to>
Returns the φ-quantile (0 ≤ φ ≤ 1) of the values across the input vector.
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="φ (scalar)">
    Quantile value (0 ≤ φ ≤ 1).
  </definition>
  <definition term="v (instant_vector)">
    Instant vector input.
  </definition>
</definitions>

**Example**
```
quantile(0.9, http_request_duration_seconds)
```

**Differences from Prometheus**
Computed using the Elasticsearch t-digest percentile aggregation, so results are approximate and may differ slightly from Prometheus's exact linear interpolation, particularly for small sample sets.

## `stddev`

<applies-to>Elastic Stack: Preview in 9.4</applies-to>
Calculates the population standard deviation across the input vector.
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="v (instant_vector)">
    Instant vector input.
  </definition>
</definitions>

**Example**
```
stddev(http_requests_total)
```


## `stdvar`

<applies-to>Elastic Stack: Preview in 9.4</applies-to>
Calculates the population variance across the input vector.
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="v (instant_vector)">
    Instant vector input.
  </definition>
</definitions>

**Example**
```
stdvar(http_requests_total)
```


## `sum`

<applies-to>Elastic Stack: Preview in 9.4</applies-to>
Calculates the sum of the values across the input vector.
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="v (instant_vector)">
    Instant vector input.
  </definition>
</definitions>

**Example**
```
sum(http_requests_total)
```