PromQL functions
These functions are based on the Prometheus query functions. Refer to the Prometheus documentation for the full semantics, and note any Elasticsearch-specific differences called out per function.
Functions that take a range vector and return an instant vector.
Range vector function list
absent_over_timeReturns
1if the range vector has no elements, and0otherwise.avg_over_timeReturns the average value of all points in the specified time range.
count_over_timeReturns the count of all values in the specified time range.
deltaCalculates the difference between the first and last value of each time series in a range vector.
derivCalculates the per-second derivative of the time series using simple linear regression.
first_over_timeReturns the first value of each time series in the specified time range.
ideltaCalculates the difference between the last two samples of each time series in a range vector.
increaseCalculates the increase in the time series in the range vector, adjusting for counter resets.
irateCalculates the per-second instant rate of increase based on the last two data points.
last_over_timeReturns the most recent value of each time series in the specified time range.
max_over_timeReturns the maximum value of all points in the specified time range.
min_over_timeReturns the minimum value of all points in the specified time range.
present_over_timeReturns
1if the range vector has at least one element, and0otherwise.quantile_over_timeReturns the φ-quantile (0 ≤ φ ≤ 1) of the values in the specified time range.
rateCalculates the per-second average rate of increase of the time series in the range vector.
stddev_over_timeReturns the population standard deviation of the values in the specified time range.
stdvar_over_timeReturns the population variance of the values in the specified time range.
sum_over_timeReturns the sum of all values in the specified time range.
Functions that aggregate an instant vector across series.
Aggregation function list
avgCalculates the average of the values across the input vector.
countCounts the number of elements in the input vector.
maxReturns the maximum value across the input vector.
minReturns the minimum value across the input vector.
quantileReturns the φ-quantile (0 ≤ φ ≤ 1) of the values across the input vector.
stddevCalculates the population standard deviation across the input vector.
stdvarCalculates the population variance across the input vector.
sumCalculates the sum of the values across the input vector.
Functions that operate on histogram metrics.
Histogram function list
histogram_quantileReturns the φ-quantile of a classic histogram represented by cumulative
lebuckets.
Mathematical, trigonometric, and rounding functions.
Math function list
absReturns the input vector with all sample values converted to their absolute value.
acosCalculates the arccosine of all elements in the input vector.
acoshCalculates the inverse hyperbolic cosine of all elements in the input vector.
asinCalculates the arcsine of all elements in the input vector.
asinhCalculates the inverse hyperbolic sine of all elements in the input vector.
atanCalculates the arctangent of all elements in the input vector.
atanhCalculates the inverse hyperbolic tangent of all elements in the input vector.
ceilRounds the sample values of all elements up to the nearest integer.
clampClamps the sample values of all elements to be within [min, max].
clamp_maxClamps the sample values of all elements to have an upper limit of max.
clamp_minClamps the sample values of all elements to have a lower limit of min.
cosCalculates the cosine of all elements in the input vector.
coshCalculates the hyperbolic cosine of all elements in the input vector.
degConverts input values from radians to degrees for all elements in the input vector.
expCalculates the exponential function for all elements in the input vector.
floorRounds the sample values of all elements down to the nearest integer.
lnCalculates the natural logarithm for all elements in the input vector.
log10Calculates the decimal logarithm for all elements in the input vector.
log2Calculates the binary logarithm for all elements in the input vector.
piReturns the value of pi.
radConverts input values from degrees to radians for all elements in the input vector.
roundRounds the sample values to the nearest integer, or to the nearest multiple of the optional argument.
sgnReturns the sign of the sample values: -1 for negative, 0 for zero, and 1 for positive values.
sinCalculates the sine of all elements in the input vector.
sinhCalculates the hyperbolic sine of all elements in the input vector.
sqrtCalculates the square root of all elements in the input vector.
tanCalculates the tangent of all elements in the input vector.
tanhCalculates the hyperbolic tangent of all elements in the input vector.
Functions that extract date and time components from timestamps.
Date and time function list
day_of_monthReturns the day of the month for each of the input timestamps (in UTC). Returned values are from 1 to 31.
day_of_weekReturns 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_yearReturns the day of the year for each of the input timestamps (in UTC). Returned values are from 1 to 366.
days_in_monthReturns the number of days in the month for each of the input timestamps (in UTC). Returned values are from 28 to 31.
hourReturns the hour of the day for each of the input timestamps (in UTC). Returned values are from 0 to 23.
minuteReturns the minute of the hour for each of the input timestamps (in UTC). Returned values are from 0 to 59.
monthReturns the month of the year for each of the input timestamps (in UTC). Returned values are from 1 to 12.
timeReturns 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.
yearReturns the year for each of the input timestamps (in UTC).
Functions that convert between scalars and instant vectors.
Conversion function list
The following PromQL functions are recognized but not yet supported in Elasticsearch. Using them returns a client error (4xx):
absentbottomkchangescount_valuesgrouphistogram_avghistogram_counthistogram_fractionhistogram_stddevhistogram_stdvarhistogram_sumholt_winterslabel_joinlabel_replacemad_over_timepredict_linearresetssortsort_desctimestamptopk