Basic PromQL Querying

All Topics

Scalar Arithmetic

Scalar Arithmetic

PromQL works as a calculator.

(2 + 3 / 6) * 2^2

Returns the scalar value 10.

Supported arithmetic operators: +, -, *, /, % (modulo), ^ (power).

Multiply a vector by a scalar. Operations between a vector and a scalar are applied to every element:

demo_batch_last_run_processed_bytes{job="demo"} / 1024^3

This converts bytes to GiB for every series in the result.

Comparison operators can filter series:

  • ==, !=, >, <, >=, <=
http_requests_total{job="demo"} > 1000

By default, comparisons drop series that don't match. Add bool to return 0/1 instead:

http_requests_total{job="demo"} > bool 1000