Introduction Querying Metrics
Querying
- Prometheus provides a functional expression language called PromQL
- Provides built in operators and functions
- Vector-based calculations like Excel
- Expressions over time-series vectors
- PromQL is read-only
- Example:
- 100 - (avg by (instance) (irate(node_cpu_seconds_total{job='node_exporter',mode="idle"}[5m])) * 100)
Querying - Expressions
- Instance vector
- a set of time series containing a single sample for each time series, all sharing the same timestamp
- Example:
- node_cpu_secounds_total
- Range vector
- a set of time series containing a range of data points over time for each time series
- Example:
- node_cpu_seconds_total[5m]
- Scalar
- a simple numeric floating point value
- Example:
- -3.14
- String
- a simple string value; currently unused
Querying - Operators
- Arithmetic binary operators
- Example:
Operators description - subtraction * multiplication / division % modulo ^ power/exponentiation)
- Example:
- Comparison binary operators
- Example:
Operators description == equal != not-equal > greater-then < less-than >= greater-or-equal <= less-or-equal
- Example:
- Logical/set binary operators
- Example:
Operators description and intersection or union unless complement
- Example:
- Aggregation operators
- Example:
Operators description sum calculate sum over dimensions min select minimum over dimensions max select maximum over dimensions avg calculate the average over dimensions stddev calculate population standard deviation over dimensions stdvar calculate population standard variance over dimensions count count number of elements in the vector count_values count number of elements with the same value bottomk smallest k elements by sample value topk largest k elements by sample value quantile calculate over dimensions
- Example:
0 Comments