Selecting a Metric by Name
The simplest PromQL query is just the metric name. Type http_requests_total into the Prometheus expression browser and you get back an Instant Vector — one row per unique combination of labels that Prometheus has seen for that metric, each showing its current value (e.g. one row per job/instance/method/status combination, each with its own request count).
Each row is a time series — a unique metric identity defined by its name plus its label set.
Label Filters
You rarely want every time series. You narrow the selection using label matchers inside {}.
| Matcher | Syntax | Meaning |
|---|---|---|
| Equals | {job="api-server"} |
Exact string match |
| Not Equals | {job!="batch-job"} |
Exclude this value |
| Regex Match | {handler=~"/api/v1/.*"} |
RE2 regex — must match the full string |
| Regex Exclude | {handler!~"/health.*"} |
Exclude anything matching the regex |
For example, filtering to just errors on the API server means matching job="api-server" and status="500" together, while excluding health-check noise means adding a regex-exclude matcher against the handler label for /health, /ready, and /metrics.
This filtering capability is why a consistent label taxonomy across your services is so critical. If half your services label the HTTP method as method and the other half use http_method, you cannot write a single query that covers both.
Interviewers often ask: "What is the difference between an Instant Vector and a Range Vector in PromQL?" The clean answer: an Instant Vector returns one sample per time series (the most recent value), while a Range Vector returns a sequence of samples over a time window (e.g., [5m]). Range Vectors cannot be graphed directly — they must be passed into a function like rate() or delta() first. Confusing these two types is the most common beginner PromQL mistake.