Prometheus
Data Model & PromQL
Master the label-based time-series model and the query language that makes it powerful.
Every Prometheus time series is uniquely identified by a metric name plus a set of key/value labels — for example http_requests_total{method="GET", code="200"}. Labels are the core dimension: they let you slice and aggregate the same metric across endpoints, instances, or status codes. Four metric types structure how you read them: counters (monotonic totals), gauges (values that go up and down), histograms (bucketed distributions), and summaries (client-side quantiles).
A spreadsheet where every row is tagged with several columns; PromQL is the pivot-table engine that lets you group by any column and compute rates or percentiles on the fly.
Key Concepts
1
PromQL is the query language over this model. You select series with matchers, apply functions like rate() to turn a counter into a per-second rate, then aggregate with operators like sum by (...) or histogram_quantile() to get percentiles. The combination — rate over a range, then aggregate by labels — is the backbone of nearly every dashboard and alert. Understanding counters vs gauges and why you almost always rate() a counter is the most common interview point.
2
What the interviewer is probing.
What the interviewer is probing.
3
1. "What identifies a time series?" *Probing:* the fundamentals. *Stalls:* "The name." *Moves
up:* the metric name plus the full set of label key-value pairs — change one label value and it is a
different series.
1. "What identifies a time series?"
4
2. "Why is rate() needed on a counter?" *Probing:* the classic. *Stalls:* "It is not." *Moves
up:* a counter only increases and resets on restart; rate gives per-second change and handles the
reset correctly.
2. "Why is rate() needed on a counter?"
5
3. "What is the cardinality problem?" *Probing:* the operational killer. *Stalls:* "Nothing."
*Moves up:* each label combination is a stored series, so a user id label creates millions and
exhausts memory.
3. "What is the cardinality problem?"
6
4. "What is the difference between a histogram and a summary?" *Probing:* the depth. *Stalls:*
"Nothing." *Moves up:* histograms bucket server-side and are aggregatable across instances;
summaries compute quantiles client-side and cannot be averaged meaningfully.
4. "What is the difference between a histogram and a summary?"