Prometheus Query Best Practices Cheat Sheet

Write performant, clear PromQL

Last Updated: November 21, 2025

Focus Areas

Focus
Use recording rules for expensive aggregations
Sort labels consistently to make queries predictable

Commands & Queries

sum by(job) (rate(http_requests_total[5m]))
Aggregate request rates per job
max_over_time(up[6h])
Check uptime windows before alerting
promtool query rules rules.yml
Lint recording and alerting rules

Summary

Lean on precomputed recording rules, limit lookback windows, and keep dashboards fast.

💡 Pro Tip: Prefer recording rules and vector selectors under two minutes.
← Back to DevOps & Cloud | Browse all categories | View all cheat sheets