Math functions
These functions perform mathematical, trigonometric, and rounding operations on instant vectors.
Returns the input vector with all sample values converted to their absolute value.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
abs(rate(http_requests_total[5m]))
Differences from Prometheus
For the minimum integer or long value, whose absolute value cannot be represented, Elasticsearch returns null and emits a warning. Prometheus, which operates on floating-point values, returns the absolute value instead.
Calculates the arccosine of all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
acos(some_metric)
Differences from Prometheus
For inputs outside the range [-1, 1], Elasticsearch returns null and emits a warning, rather than the NaN that Prometheus returns.
Calculates the inverse hyperbolic cosine of all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
acosh(some_metric)
Differences from Prometheus
For inputs below 1, Elasticsearch returns null and emits a warning, rather than the NaN that Prometheus returns.
Calculates the arcsine of all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
asin(some_metric)
Differences from Prometheus
For inputs outside the range [-1, 1], Elasticsearch returns null and emits a warning, rather than the NaN that Prometheus returns.
Calculates the inverse hyperbolic sine of all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
asinh(some_metric)
Calculates the arctangent of all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
atan(some_metric)
Calculates the inverse hyperbolic tangent of all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
atanh(some_metric)
Differences from Prometheus
For an input whose absolute value is 1 or greater, Elasticsearch returns null and emits a warning, rather than the ±Inf or NaN that Prometheus returns.
Rounds the sample values of all elements up to the nearest integer.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
ceil(rate(http_requests_total[5m]))
Clamps the sample values of all elements to be within [min, max].
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
min(scalar)- Minimum value.
max(scalar)- Maximum value.
Example
clamp(http_requests_total, 0, 100)
Differences from Prometheus
Does not implement Prometheus's special case of returning an empty vector when min is greater than max; it always returns clamped values.
Clamps the sample values of all elements to have an upper limit of max.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
max(scalar)- Maximum value.
Example
clamp_max(http_requests_total, 100)
Clamps the sample values of all elements to have a lower limit of min.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
min(scalar)- Minimum value.
Example
clamp_min(http_requests_total, 0)
Calculates the cosine of all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
cos(some_metric)
Calculates the hyperbolic cosine of all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
cosh(some_metric)
Differences from Prometheus
On numeric overflow for large-magnitude inputs, Elasticsearch returns null and emits a warning, rather than the ±Inf that Prometheus returns.
Converts input values from radians to degrees for all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
deg(some_metric)
Differences from Prometheus
For NaN or infinite inputs, Elasticsearch returns null and emits a warning, instead of returning the value unchanged.
Calculates the exponential function for all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
exp(rate(http_requests_total[5m]))
Rounds the sample values of all elements down to the nearest integer.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
floor(rate(http_requests_total[5m]))
Calculates the natural logarithm for all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
ln(memory_usage_bytes)
Differences from Prometheus
For an input of zero or a negative number, Elasticsearch returns null and emits a warning, rather than the -Inf (for zero) or NaN (for negatives) that Prometheus returns.
Calculates the decimal logarithm for all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
log10(http_requests_total)
Differences from Prometheus
For an input of zero or a negative number, Elasticsearch returns null and emits a warning, rather than the -Inf (for zero) or NaN (for negatives) that Prometheus returns.
Calculates the binary logarithm for all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
log2(memory_usage_bytes)
Differences from Prometheus
For an input of zero or a negative number, Elasticsearch returns null and emits a warning, rather than the -Inf (for zero) or NaN (for negatives) that Prometheus returns.
Returns the value of pi.
Return type
scalar
Example
pi()
Converts input values from degrees to radians for all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
rad(some_metric)
Rounds the sample values to the nearest integer, or to the nearest multiple of the optional argument.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
to_nearest(scalar, optional)- Round to nearest multiple of this value.
Example
round(rate(http_requests_total[5m]))
Differences from Prometheus
With a to_nearest argument, ties round up, matching Prometheus. Called with a single argument, a NaN input returns 0 instead of NaN.
Returns the sign of the sample values: -1 for negative, 0 for zero, and 1 for positive values.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
sgn(delta(queue_depth[5m]))
Calculates the sine of all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
sin(some_metric)
Calculates the hyperbolic sine of all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
sinh(some_metric)
Differences from Prometheus
On numeric overflow for large-magnitude inputs, Elasticsearch returns null and emits a warning, rather than the ±Inf that Prometheus returns.
Calculates the square root of all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
sqrt(http_requests_total)
Differences from Prometheus
For a negative input, Elasticsearch returns null and emits a warning, rather than the NaN that Prometheus returns.
Calculates the tangent of all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
tan(some_metric)
Calculates the hyperbolic tangent of all elements in the input vector.
Return type
instant_vector
Parameters
v(instant_vector)- Instant vector input.
Example
tanh(some_metric)