PromQL (Prometheus Query Language) is the query language for Prometheus, with common functions including:
Aggregation Functions:
sum()- Summationavg()- Averagemax()- Maximummin()- Minimumcount()- Countcount_values()- Count occurrences of each value
Time Functions:
rate()- Calculate average growth rate over a time windowirate()- Calculate instantaneous growth rate (more sensitive)increase()- Calculate increment over a time windowdelta()- Calculate difference
Mathematical Functions:
abs()- Absolute valueceil()- Round upfloor()- Round downround()- Round to nearestexp()- Exponentialln()- Natural logarithm
Prediction Functions:
predict_linear()- Predict future values based on linear regression
Example Queries:
promql# Calculate QPS rate(http_requests_total[5m]) # Calculate memory usage rate sum(container_memory_usage_bytes) / sum(container_spec_memory_limit_bytes) * 100 # Predict when disk space will run out predict_linear(node_filesystem_avail_bytes[1h], 3600*24) < 0
Notes:
rate()andirate()should only be used with Counter types- Time window selection affects result accuracy
- Use
byclause for grouped aggregation