Interview's MateKubernetes
Interview's Mate

Kubernetes

K8s · Workloads · GitOps · Cloud

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Kubernetes topics
Lesson 123/ 160
07. Observability, Troubleshooting & SRE

PromQL Essentials for Cluster & Application Alerting

Write PromQL for SLIs, burn rates, and actionable Kubernetes alerts.

IntermediatePromQL · SLIs · Alerts3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

PromQL is a map of counters and gauges with labeled neighborhoods; rate measures road speed, sum selects the view, and a bucket estimate locates a percentile. The simple Kubernetes rule is: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs.

Think of it like…

PromQL is a map of counters and gauges with labeled neighborhoods; rate measures road speed, sum selects the view, and a bucket estimate locates a percentile.

Where you’ve seen it

An SRE testing a diagnosis runs kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))'. Expected evidence: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs. If the run instead shows this symptom, stop and restore the last known state: A rate on a gauge or no aggregation of duplicate Pod replicas can produce meaningless traffic or alert counts, and recording rules do not fix incorrect source labels.

Words you’ll hear

PromQL
For this lesson, PromQL is the controlling idea: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs.
SLIs
SLIs is the checkpoint; run kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))' and inspect the owner chain. A rate on a gauge or no aggregation of duplicate Pod replicas can produce meaningless traffic or alert counts, and recording rules do not fix incorrect source labels.
Alerts
Alerts is the outcome to preserve; the cost is explicit: PromQL is expressive for Kubernetes incidents, but high-cardinality labels, short lookback windows, and per-Pod dashboards can overload the server.
Verification evidence
The evidence command is kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))'. It connects the declaration to this behavior: Write PromQL for SLIs, burn rates, and actionable Kubernetes alerts.

Visual diagram

Loading interactive diagram

Theory & deep dive

How PromQL reaches the intended state

Write PromQL for SLIs, burn rates, and actionable Kubernetes alerts. PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs.

The concrete checkpoint is kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))'; compare the PromQL owner, SLIs state, and Alerts outcome instead of treating YAML acceptance as proof.

Verify SLIs, not only object creation

Run kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))' after the change and correlate the result with Events and the owning object. PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs.

Key takeaway: PromQL is implemented only when this invariant remains observable: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs.

SLIs: failure boundary and production cost

A rate on a gauge or no aggregation of duplicate Pod replicas can produce meaningless traffic or alert counts, and recording rules do not fix incorrect source labels. The prerequisite contract is concrete: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs.

PromQL is expressive for Kubernetes incidents, but high-cardinality labels, short lookback windows, and per-Pod dashboards can overload the server. A safe design limits blast radius, records the last good configuration, and uses kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))' as a deterministic rollback checkpoint.

Recover from SLIs drift

Capture the current state with kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))', then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: A rate on a gauge or no aggregation of duplicate Pod replicas can produce meaningless traffic or alert counts, and recording rules do not fix incorrect source labels.

Key takeaway: Accept the trade-off consciously: PromQL is expressive for Kubernetes incidents, but high-cardinality labels, short lookback windows, and per-Pod dashboards can overload the server.

How it works, step by step

Step 1 of 4
SRE and service owner

1. Define the symptom and SLI

Turn the user symptom into a measurable question and select a telemetry source: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs.

PromQL contract → owned state
Key numbers at this step
Goal
Write PromQL for SLIs, burn rates, and actionable Kubernetes alerts.
Owner
PromQL

When to use it & trade-offs

What it is

Write PromQL for SLIs, burn rates, and actionable Kubernetes alerts. PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs.

Why it matters: A rate on a gauge or no aggregation of duplicate Pod replicas can produce meaningless traffic or alert counts, and recording rules do not fix incorrect source labels. The invariant at risk is specific: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs. The quickest fact check before changing the design is kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))'.

When to reach for it

  • Use PromQL to enforce this invariant: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs.
  • Use SLIs evidence from kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))' in reviews and incident timelines. Write PromQL for SLIs, burn rates, and actionable Kubernetes alerts.
  • Choose the managed observability backend route only when this cost is justified by governance or scale: PromQL is expressive for Kubernetes incidents, but high-cardinality labels, short lookback windows, and per-Pod dashboards can overload the server.

When to avoid or be careful

  • Avoid assuming PromQL is complete after YAML submission; the required behavior is concrete: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs.
  • Avoid treating the next symptom as random; check the owner and state with kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))' first: A rate on a gauge or no aggregation of duplicate Pod replicas can produce meaningless traffic or alert counts, and recording rules do not fix incorrect source labels.
  • Avoid adopting a heavier platform wrapper before measuring its cost: PromQL is expressive for Kubernetes incidents, but high-cardinality labels, short lookback windows, and per-Pod dashboards can overload the server.

Native, manual, and managed paths for PromQL

Metrics and evidence-led diagnosis
Best for: Write PromQL for SLIs, burn rates, and actionable Kubernetes alerts. A concrete incident check is kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))'.

Strengths: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs.

Watch out: PromQL is expressive for Kubernetes incidents, but high-cardinality labels, short lookback windows, and per-Pod dashboards can overload the server. Recovery must also recognize this signal: A rate on a gauge or no aggregation of duplicate Pod replicas can produce meaningless traffic or alert counts, and recording rules do not fix incorrect source labels.

Ad-hoc console inspection
Best for: Quickly testing the SLIs assumption with kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))'; the expected invariant is: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs.

Strengths: kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))' gives immediate feedback without first building a platform layer.

Watch out: A manual change can hide drift, and unlike PromQL, it does not make this symptom self-documenting: A rate on a gauge or no aggregation of duplicate Pod replicas can produce meaningless traffic or alert counts, and recording rules do not fix incorrect source labels.

Managed observability backend
Best for: Teams that need Alerts integrated with guardrails; the evidence path is kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))'.

Strengths: Platform controls can wrap this exact behavior in policy or dashboards: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs.

Watch out: The added platform ownership buys value at this cost: PromQL is expressive for Kubernetes incidents, but high-cardinality labels, short lookback windows, and per-Pod dashboards can overload the server.

Interview signals & numbers to know

When this topic comes up

  • Interview anchor: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs.
  • Trace PromQL to Alerts through SLIs; the invariant is: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs.
  • Recognize the symptom: A rate on a gauge or no aggregation of duplicate Pod replicas can produce meaningless traffic or alert counts, and recording rules do not fix incorrect source labels.
  • Justify the cost: PromQL is expressive for Kubernetes incidents, but high-cardinality labels, short lookback windows, and per-Pod dashboards can overload the server.
  • Verify with kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))' instead of only inspecting YAML.

Benchmarks & rules of thumb

5m -
a common but not mandatory rate window
3 -
basic stages in useful queries: select, transform, aggregate
0 -
correct percentile from a gauge without distribution buckets

Common mistakes & follow-ups

Common interview mistakes

  • Debugging only the child object misses the PromQL owner contract: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs.
  • Ignoring this telltale condition leads to unrelated changes: A rate on a gauge or no aggregation of duplicate Pod replicas can produce meaningless traffic or alert counts, and recording rules do not fix incorrect source labels.
  • Repeating kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))' without an owner for remediation wastes retry cost. PromQL is expressive for Kubernetes incidents, but high-cardinality labels, short lookback windows, and per-Pod dashboards can overload the server.

Likely interviewer follow-ups

  • How would API output and runtime evidence prove this behavior: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs?
  • Which owner object, logs, and Events would you inspect for this symptom-A rate on a gauge or no aggregation of duplicate Pod replicas can produce meaningless traffic or alert counts, and recording rules do not fix incorrect source labels-?
  • At what threshold would this cost become unacceptable: PromQL is expressive for Kubernetes incidents, but high-cardinality labels, short lookback windows, and per-Pod dashboards can overload the server?
Interview tip: Interview sequence: state the invariant, run kubectl port-forward svc/prometheus 9090; curl -g 'http://localhost:9090/api/v1/query?query=sum(rate(http_requests_total{code=~"5.."}[5m]))', name the failure, then justify the cost. Invariant: PromQL selects labeled time series and applies functions such as rate for counters, histogram_quantile for buckets, and sum by grouping to calculate useful SLIs. Failure: A rate on a gauge or no aggregation of duplicate Pod replicas can produce meaningless traffic or alert counts, and recording rules do not fix incorrect source labels. Cost: PromQL is expressive for Kubernetes incidents, but high-cardinality labels, short lookback windows, and per-Pod dashboards can overload the server.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply PromQL Essentials for Cluster & Application Alerting with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Prometheus Architecture, ServiceMonitors & PodMonitors
Next topic
Visualizing Cluster Health with Grafana Dashboards (kube-prometheus-stack)