PromQL Basics
Cheat sheet · https://pcornel.dk/topic.php?topic=6205
Answer
PromQL is Prometheus's query language: selectors with labels, range vectors, functions such as rate(), aggregation such as sum by (), and binary operators.
Remember
rate() needs a range at least 4× the scrape interval. Aggregate after rate (sum(rate(...))). by keeps labels, without drops them. Watch for label mismatches in binary operations.
First checks
http_requests_total{job="api",code=~"5.."}— first check for this topiccurl -s localhost:9090/-/ready— Prometheus readycurl -s 'localhost:9090/api/v1/query?query=up'— scrape targets up/downpromtool check config prometheus.yml— config valid
Verify in this order
selector → range vector → function → aggregation → result
Where it usually breaks
Too short a rate() range returns gaps.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6205