﻿---
title: PromQL functions
description: PromQL function reference for Elasticsearch, grouped by category, with Elasticsearch-specific differences from Prometheus.
url: https://www.elastic.co/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions
products:
  - Elasticsearch
applies_to:
  - Elastic Cloud Serverless: Generally available
  - Elastic Stack: Preview in 9.4
---

# PromQL functions
These functions are based on the [Prometheus query functions](https://prometheus.io/docs/prometheus/latest/querying/functions/). Refer to the Prometheus documentation for the full semantics, and note any Elasticsearch-specific differences called out per function.

## Functions overview


### Range vector functions

Functions that take a range vector and return an instant vector.
<dropdown title="Range vector function list">
  - [`absent_over_time`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-absent_over_time) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns `1` if the range vector has no elements, and `0` otherwise.
  - [`avg_over_time`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-avg_over_time) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the average value of all points in the specified time range.
  - [`count_over_time`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-count_over_time) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the count of all values in the specified time range.
  - [`delta`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-delta) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the difference between the first and last value of each time series in a range vector.
  - [`deriv`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-deriv) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the per-second derivative of the time series using simple linear regression.
  - [`first_over_time`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-first_over_time) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the first value of each time series in the specified time range.
  - [`idelta`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-idelta) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the difference between the last two samples of each time series in a range vector.
  - [`increase`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-increase) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the increase in the time series in the range vector, adjusting for counter resets.
  - [`irate`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-irate) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the per-second instant rate of increase based on the last two data points.
  - [`last_over_time`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-last_over_time) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the most recent value of each time series in the specified time range.
  - [`max_over_time`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-max_over_time) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the maximum value of all points in the specified time range.
  - [`min_over_time`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-min_over_time) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the minimum value of all points in the specified time range.
  - [`present_over_time`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-present_over_time) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns `1` if the range vector has at least one element, and `0` otherwise.
  - [`quantile_over_time`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-quantile_over_time) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the φ-quantile (0 ≤ φ ≤ 1) of the values in the specified time range.
  - [`rate`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-rate) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the per-second average rate of increase of the time series in the range vector.
  - [`stddev_over_time`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-stddev_over_time) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the population standard deviation of the values in the specified time range.
  - [`stdvar_over_time`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-stdvar_over_time) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the population variance of the values in the specified time range.
  - [`sum_over_time`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/range-vector#promql-fn-sum_over_time) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the sum of all values in the specified time range.
</dropdown>


### Aggregation functions

Functions that aggregate an instant vector across series.
<dropdown title="Aggregation function list">
  - [`avg`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/aggregation#promql-fn-avg) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the average of the values across the input vector.
  - [`count`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/aggregation#promql-fn-count) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Counts the number of elements in the input vector.
  - [`max`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/aggregation#promql-fn-max) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the maximum value across the input vector.
  - [`min`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/aggregation#promql-fn-min) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the minimum value across the input vector.
  - [`quantile`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/aggregation#promql-fn-quantile) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the φ-quantile (0 ≤ φ ≤ 1) of the values across the input vector.
  - [`stddev`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/aggregation#promql-fn-stddev) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the population standard deviation across the input vector.
  - [`stdvar`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/aggregation#promql-fn-stdvar) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the population variance across the input vector.
  - [`sum`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/aggregation#promql-fn-sum) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the sum of the values across the input vector.
</dropdown>


### Histogram functions

Functions that operate on histogram metrics.
<dropdown title="Histogram function list">
  - [`histogram_quantile`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/histogram#promql-fn-histogram_quantile) <applies-to>Elastic Stack: Planned</applies-to>
    Returns the φ-quantile of a classic histogram represented by cumulative `le` buckets.
</dropdown>


### Math functions

Mathematical, trigonometric, and rounding functions.
<dropdown title="Math function list">
  - [`abs`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-abs) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the input vector with all sample values converted to their absolute value.
  - [`acos`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-acos) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the arccosine of all elements in the input vector.
  - [`acosh`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-acosh) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the inverse hyperbolic cosine of all elements in the input vector.
  - [`asin`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-asin) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the arcsine of all elements in the input vector.
  - [`asinh`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-asinh) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the inverse hyperbolic sine of all elements in the input vector.
  - [`atan`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-atan) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the arctangent of all elements in the input vector.
  - [`atanh`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-atanh) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the inverse hyperbolic tangent of all elements in the input vector.
  - [`ceil`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-ceil) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Rounds the sample values of all elements up to the nearest integer.
  - [`clamp`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-clamp) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Clamps the sample values of all elements to be within [min, max].
  - [`clamp_max`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-clamp_max) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Clamps the sample values of all elements to have an upper limit of max.
  - [`clamp_min`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-clamp_min) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Clamps the sample values of all elements to have a lower limit of min.
  - [`cos`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-cos) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the cosine of all elements in the input vector.
  - [`cosh`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-cosh) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the hyperbolic cosine of all elements in the input vector.
  - [`deg`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-deg) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Converts input values from radians to degrees for all elements in the input vector.
  - [`exp`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-exp) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the exponential function for all elements in the input vector.
  - [`floor`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-floor) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Rounds the sample values of all elements down to the nearest integer.
  - [`ln`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-ln) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the natural logarithm for all elements in the input vector.
  - [`log10`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-log10) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the decimal logarithm for all elements in the input vector.
  - [`log2`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-log2) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the binary logarithm for all elements in the input vector.
  - [`pi`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-pi) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the value of pi.
  - [`rad`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-rad) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Converts input values from degrees to radians for all elements in the input vector.
  - [`round`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-round) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Rounds the sample values to the nearest integer, or to the nearest multiple of the optional argument.
  - [`sgn`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-sgn) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the sign of the sample values: -1 for negative, 0 for zero, and 1 for positive values.
  - [`sin`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-sin) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the sine of all elements in the input vector.
  - [`sinh`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-sinh) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the hyperbolic sine of all elements in the input vector.
  - [`sqrt`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-sqrt) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the square root of all elements in the input vector.
  - [`tan`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-tan) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the tangent of all elements in the input vector.
  - [`tanh`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/math#promql-fn-tanh) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Calculates the hyperbolic tangent of all elements in the input vector.
</dropdown>


### Date and time functions

Functions that extract date and time components from timestamps.
<dropdown title="Date and time function list">
  - [`day_of_month`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/date-time#promql-fn-day_of_month) <applies-to>Elastic Stack: Planned</applies-to>
    Returns the day of the month for each of the input timestamps (in UTC). Returned values are from 1 to 31.
  - [`day_of_week`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/date-time#promql-fn-day_of_week) <applies-to>Elastic Stack: Planned</applies-to>
    Returns the day of the week for each of the input timestamps (in UTC). Returned values are from 0 to 6, where 0 means Sunday.
  - [`day_of_year`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/date-time#promql-fn-day_of_year) <applies-to>Elastic Stack: Planned</applies-to>
    Returns the day of the year for each of the input timestamps (in UTC). Returned values are from 1 to 366.
  - [`days_in_month`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/date-time#promql-fn-days_in_month) <applies-to>Elastic Stack: Planned</applies-to>
    Returns the number of days in the month for each of the input timestamps (in UTC). Returned values are from 28 to 31.
  - [`hour`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/date-time#promql-fn-hour) <applies-to>Elastic Stack: Planned</applies-to>
    Returns the hour of the day for each of the input timestamps (in UTC). Returned values are from 0 to 23.
  - [`minute`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/date-time#promql-fn-minute) <applies-to>Elastic Stack: Planned</applies-to>
    Returns the minute of the hour for each of the input timestamps (in UTC). Returned values are from 0 to 59.
  - [`month`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/date-time#promql-fn-month) <applies-to>Elastic Stack: Planned</applies-to>
    Returns the month of the year for each of the input timestamps (in UTC). Returned values are from 1 to 12.
  - [`time`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/date-time#promql-fn-time) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the number of seconds since January 1, 1970 UTC. Note that this does not actually return the current time, but the time at which the expression is being evaluated.
  - [`year`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/date-time#promql-fn-year) <applies-to>Elastic Stack: Planned</applies-to>
    Returns the year for each of the input timestamps (in UTC).
</dropdown>


### Conversion functions

Functions that convert between scalars and instant vectors.
<dropdown title="Conversion function list">
  - [`scalar`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/conversion#promql-fn-scalar) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the sample value of a single-element instant vector as a scalar. If the input vector does not have exactly one element, scalar returns NaN.
  - [`vector`](/elastic/docs-builder/docs/3562/reference/query-languages/promql/functions/conversion#promql-fn-vector) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the scalar as a vector with no labels.
</dropdown>


## Not yet supported

The following PromQL functions are recognized but not yet supported in Elasticsearch. Using them returns a client error (4xx):
- `absent`
- `bottomk`
- `changes`
- `count_values`
- `group`
- `histogram_avg`
- `histogram_count`
- `histogram_fraction`
- `histogram_stddev`
- `histogram_stdvar`
- `histogram_sum`
- `holt_winters`
- `label_join`
- `label_replace`
- `mad_over_time`
- `predict_linear`
- `resets`
- `sort`
- `sort_desc`
- `timestamp`
- `topk`