PromQL operators
These operators are based on the Prometheus operators. Refer to the Prometheus documentation for the full semantics, and note any Elasticsearch-specific differences called out per operator.
Binary operators that perform arithmetic between scalars and instant vectors.
Arithmetic operator list
+(add)Adds the two operands element-wise. For vector–vector operations, the metric name is dropped.
/(div)Divides the left operand by the right operand element-wise. For vector–vector operations, the metric name is dropped.
%(mod)Returns the remainder of dividing the left operand by the right operand element-wise. For vector–vector operations, the metric name is dropped.
*(mul)Multiplies the two operands element-wise. For vector–vector operations, the metric name is dropped.
^(pow)Raises the left operand to the power of the right operand element-wise. For vector–vector operations, the metric name is dropped.
-(sub)Subtracts the right operand from the left operand element-wise. For vector–vector operations, the metric name is dropped.
Binary operators that filter instant vectors or, with the bool modifier, return 0 or 1.
Comparison operator list
==(eq)Compares elements for equality. By default, acts as a filter. With the bool modifier, returns 0 or 1.
>(gt)Compares elements where the left operand is greater than the right. By default, acts as a filter. With the bool modifier, returns 0 or 1.
>=(gte)Compares elements where the left operand is greater than or equal to the right. By default, acts as a filter. With the bool modifier, returns 0 or 1.
<(lt)Compares elements where the left operand is less than the right. By default, acts as a filter. With the bool modifier, returns 0 or 1.
<=(lte)Compares elements where the left operand is less than or equal to the right. By default, acts as a filter. With the bool modifier, returns 0 or 1.
!=(neq)Compares elements for inequality. By default, acts as a filter. With the bool modifier, returns 0 or 1.
Binary operators that combine two instant vectors by matching their label sets.
Logical/set operator list
orReturns all elements from the left vector plus elements from the right vector that have no matching label sets in the left.
Operators that apply to a single instant vector or scalar.
Unary operator list
-(neg)Negates the instant vector or scalar by inverting the sign of each sample value.
Operators used inside instant vector selectors ({...}) to match series by label.
Label matching operator list
=(label_eq)Matches labels exactly equal to the provided string.
!=(label_neq)Matches labels not equal to the provided string.
!~(label_nre)Matches labels whose value does not satisfy the provided regular expression.
=~(label_re)Matches labels whose value satisfies the provided regular expression.
PromQL follows the same binary operator precedence as Prometheus. The following list orders operators from highest to lowest precedence; operators listed together share the same precedence level:
^*,/,%,atan2+,-==,!=,<=,<,>=,>and,unlessor
^ is right-associative; all other binary operators are left-associative. Use parentheses to override the default precedence.
atan2, and, and unless are listed here for completeness, but are not evaluated yet in Elasticsearch. See Not yet supported and PromQL limitations.
When a binary operator is applied between two instant vectors, PromQL matches samples that have identical label sets (one-to-one matching). Prometheus provides modifiers that change which labels are considered (on(...) and ignoring(...)) and that enable many-to-one and one-to-many matching (group_left and group_right).
Elasticsearch does not support the on(...), ignoring(...), group_left, or group_right vector matching modifiers yet. Using them returns a client error (4xx). See PromQL limitations.
By default, a comparison operator between two instant vectors acts as a filter: samples that do not satisfy the comparison are dropped, and matching samples keep their original values. Appending the bool modifier changes this behavior so that the comparison returns 0 for false and 1 for true, and keeps every sample. The bool modifier is required when comparing two scalars.
Example
requests_total > bool 256
Prometheus documents aggregation operators (such as sum, avg, min, max, and count) on its operators page. In Elasticsearch PromQL, these are documented as aggregation functions.
The following Prometheus operators are not supported in Elasticsearch PromQL yet:
</>/andatan2unless