﻿---
title: PromQL operators
description: PromQL operator reference for Elasticsearch, grouped by category, with Elasticsearch-specific differences from Prometheus.
url: https://docs-v3-preview.elastic.dev/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators
products:
  - Elasticsearch
applies_to:
  - Elastic Cloud Serverless: Generally available
  - Elastic Stack: Preview in 9.4
---

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

## Operators overview


### Arithmetic operators

Binary operators that perform arithmetic between scalars and instant vectors.
<dropdown title="Arithmetic operator list">
  - [`+` (add)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/arithmetic#promql-op-add) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Adds the two operands element-wise. For vector–vector operations, the metric name is dropped.
  - [`/` (div)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/arithmetic#promql-op-div) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Divides the left operand by the right operand element-wise. For vector–vector operations, the metric name is dropped.
  - [`%` (mod)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/arithmetic#promql-op-mod) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns the remainder of dividing the left operand by the right operand element-wise. For vector–vector operations, the metric name is dropped.
  - [`*` (mul)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/arithmetic#promql-op-mul) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Multiplies the two operands element-wise. For vector–vector operations, the metric name is dropped.
  - [`^` (pow)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/arithmetic#promql-op-pow) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Raises the left operand to the power of the right operand element-wise. For vector–vector operations, the metric name is dropped.
  - [`-` (sub)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/arithmetic#promql-op-sub) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Subtracts the right operand from the left operand element-wise. For vector–vector operations, the metric name is dropped.
</dropdown>


### Comparison operators

Binary operators that filter instant vectors or, with the `bool` modifier, return `0` or `1`.
<dropdown title="Comparison operator list">
  - [`==` (eq)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/comparison#promql-op-eq) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Compares elements for equality. By default, acts as a filter. With the bool modifier, returns 0 or 1.
  - [`>` (gt)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/comparison#promql-op-gt) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    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)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/comparison#promql-op-gte) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    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)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/comparison#promql-op-lt) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    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)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/comparison#promql-op-lte) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    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)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/comparison#promql-op-neq) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Compares elements for inequality. By default, acts as a filter. With the bool modifier, returns 0 or 1.
</dropdown>


### Logical/set operators

Binary operators that combine two instant vectors by matching their label sets.
<dropdown title="Logical/set operator list">
  - [`or`](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/logical-set#promql-op-or) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Returns all elements from the left vector plus elements from the right vector that have no matching label sets in the left.
</dropdown>


### Unary operators

Operators that apply to a single instant vector or scalar.
<dropdown title="Unary operator list">
  - [`-` (neg)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/unary#promql-op-neg) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Negates the instant vector or scalar by inverting the sign of each sample value.
</dropdown>


### Label matching operators

Operators used inside instant vector selectors (`{...}`) to match series by label.
<dropdown title="Label matching operator list">
  - [`=` (label_eq)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/label-matching#promql-op-label_eq) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Matches labels exactly equal to the provided string.
  - [`!=` (label_neq)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/label-matching#promql-op-label_neq) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Matches labels not equal to the provided string.
  - [`!~` (label_nre)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/label-matching#promql-op-label_nre) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Matches labels whose value does not satisfy the provided regular expression.
  - [`=~` (label_re)](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/label-matching#promql-op-label_re) <applies-to>Elastic Stack: Preview in 9.4</applies-to>
    Matches labels whose value satisfies the provided regular expression.
</dropdown>


## Binary operator precedence

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:
1. `^`
2. `*`, `/`, `%`, `atan2`
3. `+`, `-`
4. `==`, `!=`, `<=`, `<`, `>=`, `>`
5. `and`, `unless`
6. `or`

`^` is right-associative; all other binary operators are left-associative. Use parentheses to override the default precedence.
<note>
  `atan2`, `and`, and `unless` are listed here for completeness, but are not evaluated yet in Elasticsearch. See [Not yet supported](#promql-operators-not-supported) and [PromQL limitations](/elastic/elasticsearch/tree/main/reference/query-languages/promql/promql-limitations#promql-limitations-unsupported-constructs).
</note>


## Vector matching

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](/elastic/elasticsearch/tree/main/reference/query-languages/promql/promql-limitations#promql-limitations-unsupported-constructs).

## The `bool` modifier

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
```


## Aggregation operators

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](https://docs-v3-preview.elastic.dev/elastic/elasticsearch/tree/main/reference/query-languages/promql/functions/aggregation).

## Not yet supported

The following Prometheus operators are not supported in Elasticsearch PromQL yet:
- `</`
- `>/`
- `and`
- `atan2`
- `unless`