Prometheus interview questions on PromQL, metrics and alerting
Prometheus interview questions check that you understand how metrics are collected, stored and queried: the pull model, labels and cardinality, the four metric types, and PromQL functions such as rate() and histogram_quantile(). Senior rounds move to alert design, Alertmanager routing, recording rules, high availability and long-term storage. Interviewers want correct PromQL and the judgment to alert on symptoms users feel rather than on every busy CPU.
By Evin JohnPublished 9 min read
How Prometheus shows up in interviews
Prometheus is the default metrics system in Kubernetes shops, so it comes up in SRE, DevOps, platform and backend loops rather than in interviews of its own. A typical pattern: a few concept questions on the data model and metric types, a live PromQL task (write the error ratio, write the 95th percentile latency), then a scenario such as an alert that fires every night or a server whose memory keeps climbing. Platform and observability roles go further into federation, remote write, long-term stores such as Thanos or Grafana Mimir, and how you would run monitoring for many teams. Grafana is usually the front end, and Grafana interview questions covers the dashboard side.
Fundamentals
| Question | What it tests | What a strong answer shows |
|---|---|---|
| Pull versus push: why does Prometheus scrape? | Architecture | The server decides what to collect and how often, a failed scrape is itself a signal (the up metric drops to 0), and targets need no knowledge of the monitoring system. Push suits short-lived jobs, which is what the Pushgateway is for. |
| What is a time series in Prometheus? | Data model | A metric name plus a unique set of labels, such as http_requests_total{method="GET", code="200", instance="api-1"}. Each series holds samples: a float value and a millisecond timestamp. |
| Name the four metric types. | Instrumentation | Counter (only increases, resets on restart), gauge (goes up and down, such as queue depth or memory), histogram (counts observations into cumulative buckets plus _sum and _count) and summary (client-side quantiles over a sliding window). |
| How does Prometheus find its targets? | Service discovery | Static configs for fixed hosts, and discovery integrations for Kubernetes, cloud providers, Consul, DNS or files. Relabeling then keeps, drops or rewrites targets and labels before the scrape. |
| What is an exporter? | Ecosystem | A process that translates another system's stats into the Prometheus format: node_exporter for host metrics, blackbox_exporter for probing endpoints from outside, kube-state-metrics for Kubernetes object state, and many database exporters. |
| When should you use the Pushgateway? | Common misuse | Only for batch jobs that end before they can be scraped, such as a nightly backup reporting its last success time. It is not a general push path: it never forgets a series on its own and hides whether the job is healthy. |
| Instant vector versus range vector? | PromQL basics | An instant vector has one sample per series at the evaluation time. A range vector, written with brackets like [5m], has all samples in a window and is what rate() and other _over_time functions take. |
| What does the up metric tell you? | Monitoring the monitor | Prometheus writes up=1 for each successful scrape and up=0 for a failure, so alerting on up == 0 per job catches dead targets and broken discovery. |
Intermediate: PromQL
- rate() versus irate() versus increase()? rate() is the per-second average over the whole window and handles counter resets, so it is the default for alerts and dashboards. irate() uses only the last two samples, which shows spikes but is noisy. increase() is rate() multiplied by the window length, so it can return a fraction because of extrapolation at the window edges.
- Why must rate() come before sum()? Summing raw counters first hides the reset of a single instance, which looks like a huge drop for the total. Take the rate of each series, then aggregate: sum by (job) (rate(http_requests_total[5m])).
- How long should the range in rate() be? Long enough to hold several samples. A common rule of thumb is at least four times the scrape interval, so a 15 second scrape makes [1m] the shortest safe window.
- How do you compute the 95th percentile latency across all pods? Rate the bucket series, sum by le (and any label you want to keep), then call histogram_quantile(0.95, ...). The result is an estimate interpolated inside a bucket, so its accuracy depends on bucket boundaries.
- Histogram or summary? Histograms aggregate across instances and let you choose quantiles at query time. Summaries give precise per-instance quantiles but cannot be meaningfully averaged. Pick histograms for service latency, and know that newer releases add native histograms with automatic buckets.
- What do on(), ignoring() and group_left do? They control vector matching in binary operations. group_left allows a many-to-one join, for example copying a team label from a kube info metric onto every pod series.
- How do you detect a metric that has stopped reporting? absent() or absent_over_time() returns a series when nothing matches, which catches an exporter that vanished entirely rather than one reporting zero.
- What does offset do? It shifts the evaluation time back, so rate(x[5m]) / rate(x[5m] offset 1w) compares now with the same moment last week.
# Share of requests that failed with a 5xx over the last 5 minutes
sum(rate(http_requests_total{job="checkout", code=~"5.."}[5m]))
/
sum(rate(http_requests_total{job="checkout"}[5m]))
# 95th percentile latency per route, across every instance
histogram_quantile(
0.95,
sum by (le, route) (rate(http_request_duration_seconds_bucket{job="checkout"}[5m]))
)
# Five pods using the most working-set memory
topk(5, sum by (namespace, pod) (container_memory_working_set_bytes{container!=""}))def increase(samples):
"""Counter growth over a window, handling resets (no extrapolation)."""
total = 0.0
for prev, cur in zip(samples, samples[1:]):
total += cur - prev if cur >= prev else cur # a drop means the process restarted
return total
def histogram_quantile(q, buckets):
"""buckets: sorted (upper_bound, cumulative_count) pairs, last one float('inf')."""
total = buckets[-1][1]
rank = q * total
lower, prev_count = 0.0, 0.0
for upper, count in buckets:
if count >= rank:
if upper == float("inf"):
return lower # cannot interpolate into +Inf: highest finite bound
return lower + (upper - lower) * (rank - prev_count) / (count - prev_count)
lower, prev_count = upper, count
# A counter scraped every 15s; the process restarted after 130.
print(increase([100, 110, 130, 5, 20])) # 50.0 (10 + 20 + 5 + 15)
latency = [(0.1, 600), (0.25, 900), (0.5, 980), (1.0, 1000), (float("inf"), 1000)]
print(round(histogram_quantile(0.95, latency), 4)) # 0.4062
print(round(histogram_quantile(0.50, latency), 4)) # 0.0833Alerting, rules and storage
| Question | What it tests | What a strong answer shows |
|---|---|---|
| What is a recording rule and when do you need one? | Performance | A rule that evaluates an expression on a schedule and stores the result as a new series, such as job:http_requests:rate5m. Use it for expensive queries that dashboards or alerts run often, and to feed federation. |
| What does the for clause in an alerting rule do? | Alert design | The expression must stay true for that long before the alert fires, which filters out brief blips. Too long a for delays real incidents, so match it to how quickly users notice. |
| What does Alertmanager do that Prometheus does not? | Alert routing | It receives firing alerts, groups related ones into one notification, deduplicates copies from redundant servers, routes by labels to receivers such as a pager, chat or email, and applies silences and inhibition rules. |
| What is inhibition? | Noise control | Muting some alerts while another is firing, for example suppressing every service alert in a cluster while the alert that the whole cluster is unreachable is active. |
| How does Prometheus store data? | TSDB | Recent samples sit in an in-memory head block backed by a write-ahead log, then get written as immutable blocks covering about two hours, which compaction merges into larger ones. Local retention is set by time or size and defaults to about 15 days. |
| How do you make Prometheus highly available? | Reliability | Run two identical servers scraping the same targets and send both to a clustered Alertmanager, which removes duplicate notifications. Dashboards can read either one. |
| How do you keep metrics for a year or query across clusters? | Scale | remote_write to a long-term store such as Thanos, Cortex, Grafana Mimir or VictoriaMetrics, or a Thanos sidecar that uploads blocks to object storage. Federation suits pulling aggregated series up a level, not copying everything. |
groups:
- name: checkout-api
rules:
- record: job:http_requests:rate5m
expr: sum by (job) (rate(http_requests_total[5m]))
- alert: CheckoutHighErrorRatio
expr: |
sum(rate(http_requests_total{job="checkout", code=~"5.."}[5m]))
/
sum(rate(http_requests_total{job="checkout"}[5m])) > 0.05
for: 10m
labels:
severity: page
annotations:
summary: "Checkout 5xx ratio above 5% for 10 minutes"
runbook_url: "https://runbooks.example.com/checkout-errors"Senior and scenario questions
- Prometheus memory doubled after a release. What happened? Almost always a cardinality jump: a new label with unbounded values such as user ID, request path with IDs in it, or a pod hash. Check the TSDB status page or count series by metric name, find the label, then drop or rewrite it with metric_relabel_configs and fix the instrumentation.
- An alert fires every night at 2 a.m. and resolves by itself. How do you handle it? Find what runs at that time (a batch job, a backup, a deploy), decide whether users are affected, and either fix the cause, tune the threshold or for duration, or route it as a ticket rather than a page. A page nobody acts on trains people to ignore pages.
- Design alerting for a service with a 99.9% availability objective. Alert on error budget burn rate, not raw error counts: a fast-burn alert over short and long windows that pages, and a slow-burn one that opens a ticket. This follows the multiwindow, multi-burn-rate approach described in Google's SRE workbook.
- What would you instrument in a new HTTP service? The RED signals: request rate, errors and duration as a histogram, labeled by route template and status class, not by raw path. Add saturation gauges such as queue depth and pool usage, and a build info gauge with the version label.
- How would you monitor one hundred Kubernetes clusters? A Prometheus per cluster (often through an operator) with short local retention, remote write or Thanos for global queries and long retention, shared recording rules, and a central Alertmanager setup with per-team routes.
- A dashboard says traffic dropped to zero but users are fine. What do you check? Whether the targets are being scraped at all (up, scrape errors, discovery changes), whether a relabel rule dropped the series, and whether a label changed name so the query no longer matches.
- Prometheus versus a hosted metrics product: what changes? Hosted tools take over storage, scaling and upgrades, often accept PromQL or remote write, and charge by series or samples. Self-hosting keeps control but makes your team own cardinality limits, upgrades and capacity.
Fictional example
- Interviewer
- Checkout feels slow to customers sometimes. Write an alert that would catch it.
- Candidate
- First I want the objective, say 95% of checkout requests under 400 milliseconds. Assuming the service exposes a latency histogram with a bucket at 0.4 seconds, I would not alert on a quantile directly, because quantiles of short windows jump around. I would compute the share of requests slower than 400 milliseconds: one minus the rate of the 0.4 second bucket divided by the rate of the count, summed across instances. Then I alert when that share stays above 5% for ten minutes, and add a longer-window check so a sustained slow drift opens a ticket. The alert routes by a service label to the checkout on-call, links a runbook, and Alertmanager groups it with any database alerts from the same cluster. If the bucket boundaries do not include 400 milliseconds, I would add that bucket first, because interpolated quantiles near a target are guesses.
How to prepare for Prometheus interview questions
- Run it locallyDownload the Prometheus binary and node_exporter for your machine, scrape both, and open the expression browser. No cluster is needed to learn PromQL.
- Instrument a tiny serviceUse an official client library to add a counter, a gauge and a latency histogram to a small HTTP app, then watch the /metrics output change as you send requests.
- Write the classic queries from memoryRequest rate by route, error ratio, p95 latency, top pods by memory, and absent() for a dead exporter.
- Write one recording rule and one alertRun promtool check rules on the file, then break a target and watch the alert move from pending to firing.
- Prepare an alert-fatigue storyA noisy alert you removed or rewrote, what signal replaced it, and how the on-call experience changed.
Prometheus questions sit next to logs and dashboards in most observability loops: Splunk interview questions covers log search and indexing, and Kubernetes interview questions explains the workloads you will be scraping. For the full role, see site reliability engineer interview questions.
PromQL is easy to read and hard to write under pressure, so rehearse saying each query out loud. In a mock round, Natively, an AI interview assistant for Mac and Windows, keeps a transcript of the conversation, can offer suggested points live, and can read a dashboard, an alert rule or a PromQL prompt from a screenshot to explain it. Add your résumé and the job description (Pro or the free trial) for answers closer to the role, then review the saved transcript and notes afterward.
Questions people ask
What are common Prometheus interview questions?
Pull versus push, the time series data model and labels, counter, gauge, histogram and summary, rate versus irate versus increase, histogram_quantile, cardinality problems, recording and alerting rules, Alertmanager, retention and high availability.
What is the difference between rate and irate in Prometheus?
rate() averages the per-second increase over the whole range and suits alerts and dashboards. irate() uses only the last two samples in the range, so it reacts to spikes but is noisy.
Should I use a histogram or a summary?
Use a histogram for service latency in most cases, because buckets can be summed across instances and quantiles chosen at query time. A summary's quantiles are computed per instance and cannot be averaged correctly.
How do I prepare for a Prometheus interview?
Run Prometheus and node_exporter locally, instrument a small service with a counter, gauge and histogram, write the classic PromQL queries from memory, and write and test one recording rule and one alert.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
