PromQL Reference¶
PromQL is a query language for Prometheus monitoring system. It allows you to select and aggregate time series data in real time. PromQL is used to create dashboards in Grafana, and to create alerts with Alertmanager.
Basic Syntax¶
A basic PromQL query can be as simple as a metric name: http_requests_total
. This will return the current value of the http_requests_total
metric.
Data Types¶
PromQL supports a variety of data types:
- Scalars:
1
,3.14
,0.5
- Strings:
"hello"
,"world"
- Vectors:
http_requests_total{job="api-server"}
- Range Vectors:
http_requests_total{job="api-server"}[5m]
Operators¶
PromQL supports a variety of operators:
- Arithmetic:
+
,-
,*
,/
,%
,^
- Comparison:
==
,!=
,>
,<
,>=
,<=
- Logical:
and
,or
,unless
Functions¶
PromQL includes a variety of functions, such as:
rate(v range-vector)
: calculates the per-second average rate of time series in a range vectorsum(v vector)
: calculates the sum of all values in the vectoravg(v vector)
: calculates the average of all values in the vector
Aggregation¶
PromQL allows you to aggregate time series: sum(http_requests_total) by (status)
. This will return the sum of http_requests_total
for each status
label value.
More Information¶
For more detailed information, refer to the official PromQL documentation and the example Prometheus queries.