Monitoring, Logging, and Observability Questions
Understanding running systems through their signals. Covers metrics, logs, and traces, instrumentation, dashboards, alerting design, and log analysis and correlation for debugging production. Emphasizes designing observability so problems are detectable and diagnosable before users are affected.
During a past incident investigation, the team discovered that key log data had already been deleted because the retention window was set too aggressively to control cost. Walk through how you'd assess that trade-off and redesign the telemetry retention policy so this is less likely to happen again, without simply keeping everything forever.
Sample Answer
Direct answer
The root problem wasn't "retention was too short," it's that retention was set as a single global cost lever without weighing it against the cost of an uninvestigable incident. The fix isn't to keep everything forever; it's to classify telemetry by investigative value and set retention per class, so the small slice of data that actually matters during an incident (errors, auth, security-relevant events) survives far longer than routine noise, at a much smaller storage cost than extending everything uniformly.
Structured elaboration
Assess what was actually lost
Before redesigning anything, pin down exactly what's missing: which time window, which services, and whether the gap overlaps anything security- or correctness-relevant (auth events, admin actions, anomalous traffic). This determines both how bad this specific incident's investigation is and which class of data needs its retention reconsidered first.
Reframe the trade-off explicitly
The original policy treated all telemetry as equally disposable after N days, which is really a decision that "the marginal value of any log past day N is lower than its storage cost," made without separating high-investigative-value data from routine debug noise. That's the actual mistake: not the number of days chosen, but applying one number uniformly across data with very different value profiles.
Redesign: risk-tiered retention, not a longer uniform window
- Classify events by investigative value: security/auth/admin actions and errors are high-value; routine info/debug logs are low-value.
- Extend retention specifically for the high-value classes; leave low-value telemetry on a short window, or shorten it further if it's not pulling its weight.
- Add compensating signals that survive even after raw logs expire: periodic metric rollups (error counts, auth-failure counts by hour) retained far longer than raw logs, and immutable, append-only storage for the highest-value security events specifically, so even a misconfigured retention job can't silently delete them early.
Process changes so this doesn't recur
Add "was retention sufficient to investigate this?" as a standing question in every incident postmortem, and put retention policy reviews on a fixed periodic cadence tied to real investigation needs (not just a cost review), so drift back toward "shorten everything to save money" gets caught before it causes another gap.
Worked example
Illustrating why targeting the high-value slice is dramatically cheaper than extending everything (stated assumptions, used to show the reasoning, not a report of a real measured deployment): suppose total daily log volume is 500 GB/day, and the classes with real investigative value (errors, auth, security-relevant events) make up 2% of that volume, i.e. 10 GB/day. The team wants to extend retention for that slice from 14 days to 90 days.
Extra storage if only the high-value 2% slice gets the extended window:
10 GB/day×(90−14) days=760 GBExtra storage if the same 90-day extension were applied to the entire 500 GB/day stream instead:
500 GB/day×(90−14) days=38,000 GB 76038,000=50Under these assumptions, extending retention for just the high-value classes costs 50x less than extending everything uniformly, for the specific data that actually would have closed this incident's investigation gap. This is the concrete argument for "keep the highest-value 2% longer" over both extremes: neither "delete everything after 14 days" (the original failure) nor "keep everything for 90+ days" (the naive overcorrection) is necessary once the data is classified by value.
Trade-offs & pitfalls
- The already-lost window for this specific incident cannot be recovered; the redesign is about preventing the next one, and being explicit about that with stakeholders avoids implying this fixes the current investigation.
- A classification scheme can miss something: an attacker or a novel failure mode can specifically target a class that wasn't extended, so periodic review of what counts as "high-value" matters as much as the initial classification.
- Immutable storage for security-relevant events adds real operational cost (it can't be casually purged even when you want to, e.g. for a legitimate data-minimization request), so scope it narrowly to what genuinely needs tamper-resistance rather than applying it broadly.
- Retention decisions made purely on cost, revisited only when a cost review happens, are exactly how this problem originates in the first place; the postmortem-triggered review is what breaks that cycle.
What is a runbook, and what does a good one actually need to contain to be useful when someone's paged at 3am? Sketch what you'd want in one for a failed database migration.
Sample Answer
Direct answer
A runbook is a step-by-step operational document for handling a specific, known failure mode: what to check first, what commands to run, when to roll back versus push forward, and who to call if it gets worse. A good one is written so that someone half-awake at 3am who has never touched this exact system before can follow it without reconstructing context from scratch. The test of a good runbook is whether a different engineer than its author can execute it correctly under pressure.
What a runbook needs to contain
- Scope and severity: what specific failure this covers, and the severity/priority it corresponds to.
- Preconditions: what access, credentials, or tools you need before starting.
- Immediate triage steps: the first few things to check, in order, to confirm the diagnosis.
- Remediation steps: copy-pasteable commands with the expected output at each step, not prose descriptions of what to do.
- Verification: how to confirm the fix actually worked, not just that the command ran.
- Rollback path: a safe way back if remediation makes things worse, including its own preconditions (e.g. "requires a backup from the last 24 hours").
- Escalation: who to page next and when, by name/role/contact, not just "escalate if needed."
- Post-incident: where to file the incident ticket, and a note to update the runbook itself if a step was wrong or missing.
Worked example: failed database migration runbook
- Scope: prod schema migration failed mid-deploy. Severity: P1 if writes are blocked, P2 if only the migration job failed cleanly.
- Triage (first 5 minutes): tail the migration tool's log for the exact error; check
SELECT count(1) FROM pg_stat_activity WHERE state <> 'idle';to see if the migration left long-running locks; check the app's error dashboard for whether requests are actually failing yet. - Remediation, case A (migration failed cleanly, nothing partially applied): re-run the migration tool in dry-run mode first, then apply.
- Remediation, case B (partially applied, schema now inconsistent): put the app in read-only/maintenance mode to stop new writes, then decide between manually completing the migration or rolling back.
- Rollback (case B, if completing isn't safe): confirm the most recent backup timestamp, pause replication, restore with
pg_restore --clean --no-owner <backup>, then run a smoke test against a few critical read/write paths before removing maintenance mode. - Verification: re-run the app's smoke tests, spot-check row counts on affected tables against the pre-migration baseline.
- Escalation: if triage doesn't identify the cause within 10 minutes, or rollback is being considered, page the on-call DBA by name/rotation, not just "the DBA team."
- Post-incident: file the incident ticket with the timeline and root cause, and if any step above was missing or wrong, fix the runbook in the same pass as the incident writeup, not "later."
Trade-offs and pitfalls
- A runbook that's too generic ("check the logs, investigate, fix it") isn't actually a runbook, it's a checklist item pretending to be one; specificity is what makes it useful at 3am when judgment is impaired by fatigue.
- Runbooks rot: a step that references a tool or dashboard that got replaced months ago is worse than no runbook, because it wastes time and erodes trust in the whole document. Tie runbook review to any change in the system it covers, not a fixed calendar cadence alone.
- Over-indexing on "never improvise" can be as dangerous as no runbook at all: a good runbook documents when to deviate (e.g. "if replication lag exceeds a set threshold, stop and escalate instead of continuing") rather than pretending every failure mode was anticipated.
- Untested runbooks are a liability. The rollback path above should actually be exercised in a drill, not just written down, since commands like
pg_restore --cleanbehave differently depending on schema ownership and extensions that may not match what was true when the runbook was written.
What's the difference between a liveness probe and a readiness probe in Kubernetes, and what goes wrong if you get them backwards or misconfigure them?
Sample Answer
Direct answer
A liveness probe answers "is this container stuck and does it need a restart," and a readiness probe answers "is this pod ready to receive traffic right now." A liveness failure triggers a container restart; a readiness failure just pulls the pod out of the Service's load-balancing endpoints without touching the running process.
How they differ
| Liveness probe | Readiness probe | |
|---|---|---|
| Question it answers | Is the process alive and unstuck? | Is the pod ready to serve traffic right now? |
| On failure | Kubelet kills and restarts the container | Pod is removed from Service endpoints, process keeps running |
| Typical use | Detect deadlocks, unrecoverable hangs | Warm-up, a dependency not yet connected, graceful shutdown draining |
| Failure cost if misconfigured | Restart loop | Traffic sent to a pod that can't serve it, or traffic starved from a healthy pod |
What goes wrong if you swap or misconfigure them
- Checking a downstream dependency on liveness instead of readiness: if a database blips, every pod fails liveness at once and Kubernetes restarts the whole fleet simultaneously, which does nothing to fix the database and creates a self-inflicted outage plus a cold-start thundering herd once it recovers (a thundering herd: every restarted instance and queued client hammers the recovering dependency at the same moment, often knocking it right back over). This is the classic swap mistake, that check belongs on readiness, not liveness.
- A readiness probe that's too permissive (always returns success regardless of dependency state): traffic gets routed to pods that can't actually serve requests, causing user-visible errors that don't show up as "pod down" in cluster-level health views.
- Aggressive timeouts or a too-short initialDelaySeconds during a slow application startup: the pod gets marked unready or killed before it's finished booting, causing flapping and cascading restarts under load, exactly when it's least affordable.
- No timeout on a probe that hits a slow dependency: a hanging health check can itself become the bottleneck, since the kubelet is now waiting on a call that may never return within the probe's own budget.
Worked example
readinessProbe:
httpGet:
path: /healthz/ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
httpGet:
path: /healthz/live
port: 8080
initialDelaySeconds: 30
periodSeconds: 20
/healthz/ready checks whether the service can actually serve traffic (connection pool warm, config loaded), while /healthz/live checks only whether the main loop is responsive and deliberately does not call out to the database. A database blip degrades readiness (pulls the pod from rotation) without triggering a mass restart, which is exactly the separation the two probe types exist to provide.
Trade-offs and pitfalls
- There's a real design decision in how deep a liveness check should go: too shallow (just "the process is running") misses real deadlocks, too deep (calling a downstream dependency) creates the mass-restart failure mode above. The right depth is "can the process make forward progress internally," not "are all my dependencies healthy."
- A startupProbe is worth using for slow-booting applications so liveness doesn't fire during a legitimately long startup, rather than just increasing initialDelaySeconds, which also delays detecting a real post-startup hang.
Your organization is comparing commercial APM/observability vendors (for example Datadog or New Relic) against a self-hosted Prometheus, Grafana, and ELK stack for an environment that mixes microservices with a legacy monolith. What criteria would you weigh most heavily, and how would you structure a proof-of-concept to validate the choice before committing?
Sample Answer
Weigh the decision on a small set of criteria that actually differ between the options in a mixed monolith-plus-microservices environment: observability depth (does it handle both the legacy monolith and the microservices equally well, not just the newer stuff), real total cost of ownership including the engineer time to run it, data residency/compliance requirements if they apply, and operational burden (who's paging when the observability stack itself breaks). Then validate the choice with a proof of concept that runs the same realistic scenarios against both options side by side, rather than trusting either a vendor's benchmark or a generic feature checklist.
Framework
Criteria that matter most in this specific environment (mixed legacy + microservices):
- Observability depth and coverage of the legacy monolith specifically. Commercial APM tools are usually strong on auto-instrumented microservices; the open-source stack's coverage of an older monolith (does an agent even exist for its stack, or does it need custom instrumentation) is often the actual differentiator, not raw feature count.
- Total cost of ownership, not just license price: for self-hosted, that includes the engineer time to run and upgrade the cluster, which teams routinely undercount because it doesn't show up as a line item the way a vendor invoice does.
- Operational burden and who owns incidents in the observability stack itself. A managed vendor takes this off your plate; self-hosted means your team is now on-call for the monitoring system too.
- Data residency and compliance, if the organization has any (regulated data, contractual data-location requirements): this can eliminate an otherwise-attractive SaaS option outright, or require a specific deployment region/mode.
- Exit path / lock-in risk: how hard is it to get your data and dashboards out if you switch later, particularly for the vendor option.
Structuring the PoC to actually validate the choice:
- Pick representative workloads from both halves of the environment: at least one path through the legacy monolith and two or three real microservices, not just the easy new-stack case.
- Instrument both candidate stacks in parallel (shadow mode) against the same real or realistic traffic, so the comparison is apples-to-apples rather than each vendor's own demo environment.
- Define success metrics up front, before running it: query latency for a realistic dashboard, cost projected at production retention/volume, and how long it took an engineer unfamiliar with the tool to build one useful dashboard and one alert from scratch.
- Include a simulated incident (inject a real failure, or replay a past one) and measure how each stack performs for actual root-cause work, not just whether data shows up.
- Run it long enough to see real cost and operational patterns, not just a demo-length window.
Worked example
A weighted scorecard makes the trade-off explicit instead of a gut call. Assign weights that sum to 1.0 across the criteria above, then score each option 1-5 per criterion (the scores below are illustrative placeholders showing how the arithmetic works; real numbers have to come from your actual PoC, not be guessed):
| Criterion | Weight | Self-hosted (Prometheus/Grafana/ELK) | Commercial APM |
|---|---|---|---|
| Observability depth | 0.30 | 3 | 5 |
| Legacy/monolith integration | 0.20 | 4 | 3 |
| Operational ease | 0.20 | 2 | 5 |
| TCO | 0.20 | 4 | 2 |
| Compliance/data residency | 0.10 | 5 | 3 |
With these illustrative inputs, the commercial option edges out, driven mainly by observability depth and operational ease outweighing its worse TCO score, given the stated weights. The value of walking through this isn't the specific 3.4 vs. 3.8, it's that the weights and scores are now visible and arguable: someone who thinks TCO should be weighted higher, or that the self-hosted operational-ease score of 2 is too harsh given the team's existing SRE capacity, can say so and change a specific number, rather than re-litigating the whole decision from scratch.
Trade-offs and pitfalls
- A weighted scorecard is only honest if the weights are set before you know how each option scores; it's common (and worth explicitly guarding against) for a team that's already leaning toward one option to unconsciously weight the criteria that favor it.
- A PoC that only tests the easy microservices case and skips the legacy monolith will miss exactly the integration gap that's most likely to bite later, since that's the part of the environment least like either vendor's demo.
- Self-hosted TCO is the number most often undercounted: engineer time spent operating, upgrading, and firefighting the observability stack itself rarely gets billed to the "observability" line item, which makes the self-hosted TCO score look better on paper than it is in practice.
- For the commercial option, data portability (can you actually export your historical data and dashboard definitions if you leave) is worth testing during the PoC, not assumed; discovering the exit path is painful only after you're already locked in defeats the purpose of evaluating lock-in risk up front.
You've got a request path that goes through three services in sequence, each with its own availability target. Users only care whether the whole request succeeded. How would you think about the end-to-end SLO, and how would you split the error budget across the teams that own those three services?
Sample Answer
Direct answer: For a serial dependency chain, the end-to-end availability is the product of each service's individual availability, not a simple average, because the request only succeeds if every hop succeeds. Once you have that end-to-end number, split the resulting error budget across the owning teams proportional to each service's own contribution to the total failure rate, with a small shared pool held back for failures that don't cleanly attribute to one team.
Structured elaboration
Why multiplication, not averaging
- If service A, B, and C are called in sequence and the user needs all three to succeed, the probability all three succeed is the product of their individual success probabilities. This is the standard independent-events multiplication rule, and it's the right model whenever failures are (approximately) independent across the three services, meaning one service failing doesn't itself cause another to fail via a shared cause.
Allocating the resulting budget
- Compute each service's own error contribution, ei=1−Si, then allocate the end-to-end budget proportionally: a service with a larger individual error rate gets a larger slice of the end-to-end budget, since it's naturally consuming more of it.
- Hold back a small shared pool (a common starting point is around 10% of the end-to-end budget) for incidents that don't have a single clear owner, a shared network layer, a common auth service, or an incident where root cause is still being investigated when the budget starts burning.
- Track each team's consumption as a ratio against their own allocation, not as a raw count, so a team with a naturally smaller allocation isn't unfairly flagged for consuming the same absolute number of failures as a team with a larger one.
Operational policy
- Give each team a burn-rate alert against their own slice, so a team gets paged and can react before the end-to-end SLO itself is at risk, catching problems at the source rather than only at the aggregate.
- If the end-to-end budget is burning but no single team's individual slice shows an obvious spike, that's the signal to draw from the shared pool and open a cross-team investigation rather than waiting for one team's dashboard to point at itself.
Worked example
Assume three services in sequence with individual monthly availabilities:
SA=0.999,SB=0.9995,SC=0.9999End-to-end availability:
Se=SA×SB×SC=0.999×0.9995×0.9999=0.99840065End-to-end error budget:
Ee=1−Se=0.00159935(≈0.15994%)Individual error contributions:
eA=1−SA=0.001,eB=1−SB=0.0005,eC=1−SC=0.0001 eA+eB+eC=0.0016Note that eA+eB+eC=0.0016 is extremely close to the exact Ee=0.00159935, this is the standard small-error approximation: for small individual error rates, the product's complement is very close to the sum of the individual complements, which is exactly why teams commonly reason about "additive" error budgets even though the underlying math is multiplicative.
Allocating the (rounded) 0.0016 end-to-end budget proportionally by contribution, after holding back a 10% shared pool:
shared pool=0.10×0.0016=0.00016 allocatable=0.0016−0.00016=0.00144Proportional shares (by each service's fraction of total individual error: A is 0.001/0.0016=62.5%, B is 0.0005/0.0016=31.25%, C is 0.0001/0.0016=6.25%):
allocA=0.625×0.00144=0.0009,allocB=0.3125×0.00144=0.00045,allocC=0.0625×0.00144=0.00009Service A, with the highest individual error rate, gets the largest allocation (0.09% of requests), which matches intuition: the least-reliable link in the chain gets the most room, and it's also the link that should be under the most reliability pressure to shrink its own eA over time.
Trade-offs & pitfalls
- Proportional allocation by raw error contribution can feel unfair to a team whose service is used by many other chains besides this one, their "share" here doesn't reflect their reliability work elsewhere. Consider whether allocation should be per-chain or aggregated across all the chains a service participates in.
- The independence assumption behind straight multiplication breaks down for correlated failures (a shared database, a shared network path, a common auth service all three depend on). A failure there hits all three services simultaneously, and treating it as three independent budget hits overstates how "used up" the chain's reliability actually is versus how concentrated the actual root cause is. This is exactly what the shared pool exists to absorb.
- A hard proportional split with no floor can effectively give a very reliable service (eC small) almost no budget at all, meaning even one legitimate incident consumes a huge fraction of their tiny allocation. A minimum floor per team avoids penalizing the already-most-reliable service disproportionately.
Unlock Full Question Bank
Get access to all Monitoring, Logging, and Observability interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.