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.
What is alert fatigue, and how would you go about preventing it on a team you're leading?
Sample Answer
Direct answer
Alert fatigue is what happens when on-call engineers get so many low-value, noisy, or duplicate pages that they start treating all alerts as probably-not-real, including the ones that matter. It's a trust problem as much as a technical one: once someone has been paged repeatedly in a night for something that turned out to be nothing, the next page, which might be the real incident, gets a slower, more skeptical response.
How I'd prevent it on a team I'm leading
- Deduplication and grouping: alerts that share a root cause (same service, same error type) should collapse into a single incident with a count, not fire a separate page per occurrence. This is usually a config change in the alerting tool (fingerprinting by service and error signature) rather than a code change.
- Severity tuning tied to required response time: not every alert deserves a page. A three-tier split (page now, notify during business hours, dashboard-only) forces every new alert to justify why it needs to interrupt someone's sleep.
- Actionable-by-default policy: no new paging alert ships without a linked runbook and a clear "what to check first." An alert with no next step is a dashboard panel that accidentally has a pager attached.
- Automated remediation for known, safe, repeatable fixes: if the same alert reliably resolves by restarting a stuck worker or clearing a queue, and that action is safe and idempotent, automate it and only page if the automated fix fails.
- A regular noise review: periodically look at which alerts fired most often and whether they led to real action; alerts that never lead to action get tuned or removed, not left running indefinitely out of habit.
Worked example
Suppose a team's on-call rotation is getting paged for "queue depth over 100" on a background job processor, firing several times a week, always self-resolving within a few minutes without anyone doing anything. Applying the framework above: first, check whether these spikes line up with a predictable traffic pattern (a nightly batch job, say) and if so, either raise the threshold above that expected peak or add a time-of-day exception. Second, if the queue really can back up unpredictably but always self-resolves within a known window without intervention, the alert should require a longer sustain window (e.g. "queue depth over 100 for 15 minutes") so it only fires when it isn't going to resolve on its own. Third, if manual intervention when it does page is always the same action (scale up worker count), that's a strong automated-remediation candidate: auto-scale on the same threshold, and only page if depth is still elevated after the auto-scale has had time to take effect.
Trade-offs and pitfalls
- Automated remediation without an audit trail or human confirmation for higher-severity cases can turn a noisy-alert problem into a silent-failure problem: the system "fixes" itself repeatedly while masking a root cause that's getting worse.
- Tuning thresholds purely to reduce page volume, without checking against real past incidents, risks quietly increasing false negatives; the goal is signal-to-noise, not just fewer pages.
- Alert fatigue prevention is not a one-time project. It needs an ongoing review cadence, because new alerts get added faster than old noisy ones get cleaned up if nobody owns the process.
An alert is firing far too often because the metric it watches has strong seasonality, or because baseline traffic differs a lot by region or tenant. How would you redesign the alerting so it stays sensitive to real regressions without the constant noise?
Sample Answer
Direct answer: Stop comparing the metric to a single number and start comparing it to what's expected for that specific time and segment: build a baseline per relevant dimension (region, tenant, hour-of-day, day-of-week), alert on deviation from that baseline rather than an absolute value, and give yourself an explicit, auditable way to suppress alerts during known, planned deviations instead of quietly widening the threshold until the alert stops meaning anything.
Structured elaboration
Diagnosing which noise source you actually have
- Seasonality noise: the metric is fine, it just has a predictable daily or weekly shape (nightly batch jobs, weekday-vs-weekend traffic) that a flat threshold can't distinguish from a real problem.
- Segment-baseline noise: different regions or tenants have genuinely different normal traffic levels, so a single global threshold is simultaneously too loose for a high-traffic segment and too tight for a low-traffic one.
- Planned-change noise: a maintenance window, migration, or intentional traffic shift temporarily makes the metric look abnormal for a known, bounded reason.
Fixing seasonality and segment noise
- Compute a rolling baseline per segment: same hour-of-day, same day-of-week, scoped to the specific region or tenant, not a single fleet-wide number.
- Alert on relative deviation from that baseline (for example, "more than 30% above the same-hour-last-week baseline for this tenant") rather than an absolute value, so a low-traffic tenant and a high-traffic tenant are each compared to their own normal, not to each other's.
- Require the deviation to persist across more than one evaluation window before paging, a single noisy data point shouldn't trigger, a sustained deviation should.
Fixing planned-change noise: explicit suppression, not silent threshold-widening
- A known nightly batch job that causes an expected spike should be handled by teaching the baseline about it (the baseline for that hour already expects the spike), not by loosening the alert threshold globally, which would also hide a real regression at that same hour.
- A planned maintenance or migration window is different: it's a one-time, bounded deviation. Use a temporary, explicitly time-boxed suppression window (start time, end time, scope, and a named owner and reason), not a permanent config change. Communicate the suppression window to on-call before it starts, and have it auto-expire and reactivate the normal alert rule at the end time rather than relying on someone remembering to turn it back on.
- Validate any new threshold or baseline against historical data (a week or two of past traffic for that segment) before relying on it in production, so the first real test of the new rule isn't the next live incident.
Worked example: switching from a global absolute count to a per-tenant relative rate
The original rule: alert if errors exceed 50 in a 5-minute window, fleet-wide.
Large tenant A, normal weekday evening peak: 80,000 requests in 5 minutes, 80 errors, an error rate of:
80,00080=0.001→0.1%This is tenant A's completely normal baseline error rate, but the absolute count (80) exceeds the global threshold (50), so it pages every weekday evening for no real reason, this is the seasonality/segment noise the question describes.
Small tenant B, normal 5-minute window: 5,000 requests, 5 errors, also a 0.1% baseline error rate. During a real regression, tenant B's error rate rises to 0.6% (30 errors out of 5,000 requests), a genuine 6x jump. Under the old absolute-count rule, 30 errors never crosses the 50-error threshold, so this real regression never pages at all.
Redesigned rule: alert if a tenant's error rate exceeds 0.5% (5x its own same-hour-last-week baseline of roughly 0.1%), sustained across two consecutive 5-minute windows.
- Tenant A's evening peak stays at 0.1%, well under the 0.5% relative threshold, so it correctly stops firing.
- Tenant B's regression at 0.6% crosses the 0.5% relative threshold and correctly fires, catching a real problem the old absolute rule missed entirely.
The same redesign both eliminates a nightly false positive on the large tenant and catches a false negative on the small tenant, because the underlying comparison changed from "count against a fleet-wide number" to "rate against this segment's own normal," which is the actual fix, not a looser or tighter version of the same rule.
Trade-offs & pitfalls
- The most common failure mode here is quietly widening a global threshold until the noise stops, which also silently raises the bar for detecting a real regression at the exact times (batch windows, planned migrations) when something is most likely to actually go wrong. Segment-and-time-aware baselines fix the noise without paying that cost.
- A suppression window with no auto-expiry is a liability: it gets forgotten, and the service runs unmonitored for that window indefinitely until someone notices during an actual incident. Auto-expiry and an explicit owner/reason on every suppression window are what make this safe to use routinely rather than a one-off hack.
- Per-segment baselines multiply the number of things that can silently drift wrong (a stale baseline for a shrinking tenant, for instance), so they need the same periodic review a static threshold does, this isn't a set-and-forget improvement over the static case, it's a more accurate model that still needs maintenance.
- Rolling changes out to alert rules and notification routing during a migration window specifically also needs a rollback plan: if the migration itself causes an unexpected real incident, the suppression window shouldn't also suppress the alert that would have caught it, scope suppression as narrowly as possible (the specific expected symptom, not the whole service) so genuine problems during the window can still page.
You're onboarding observability for a brand-new service. What do you instrument first, metrics, traces, or logs, and why? How do you keep performance and cardinality overhead in check while still leaving yourself enough to debug with later?
Sample Answer
Direct answer: Start with metrics: they are the cheapest signal to collect, they are what your alerts and SLOs are built on, and you need them from hour one to know the service is even healthy. Add structured logs next, since that is where root-cause detail lives once an alert fires. Bring in distributed traces as the service starts talking to other services, because that is when "which hop was slow" becomes the actual question. All three should exist before the service takes real traffic, this is a sequencing preference within a short onboarding window, not "ship logs-only for a month."
Structured elaboration
Metrics first: what to emit
- The four golden signals: request rate, error rate, latency (as a histogram, not an average), and saturation (CPU, memory, queue depth, connection pool usage).
- Use a counter for request/error totals, a histogram for latency (so you can compute p50/p95/p99 later), and a gauge for in-flight/concurrency.
- Emit through OpenTelemetry's metrics API so the instrumentation is vendor-neutral; export to Prometheus (pull) or via OTLP to a collector (push), whichever your platform already runs.
Logs second: structured, correlated
- JSON logs with a fixed schema: timestamp, service, severity, message, and critically trace_id/span_id so a log line can be jumped to from a trace and vice versa.
- Log at request boundaries and on errors, not on every internal function call. High-frequency debug logs belong behind a sampling flag or a log level you can raise on demand, not in the default hot path.
Traces third: selective, not universal
- Instrument service entry/exit, outbound calls (DB, cache, downstream HTTP/gRPC), and anything async (queue publish/consume).
- Do not span every internal function, coarse spans keep both storage cost and cognitive load down.
Keeping cardinality and overhead in check
- Cardinality is the product of your label combinations. The rule that matters most: never put an unbounded value (user ID, order ID, raw URL with path params, IP address) into a metric label. Use the route template (
/orders/:id, not/orders/8231) and coarse buckets like status code class (2xx/4xx/5xx) or exact code where the cardinality is bounded. - Sample traces instead of capturing all of them: a low baseline rate (order of a few percent) for normal traffic, with tail-based or error-based sampling that keeps 100% of traces containing an error or a latency outlier. That way the traces you actually need for debugging are the ones least likely to get sampled away.
- Batch and export asynchronously. Exporters (OTel SDK, Prometheus client) should never block the request path; use a bounded queue with backpressure so a slow collector degrades telemetry, not the service.
- Put a collector (OpenTelemetry Collector or an agent) between the app and the backends. It absorbs batching, retries, and protocol translation so the application code stays simple and the backend can be swapped later without redeploying every service.
Worked example: why label choice matters for cardinality
Say a metric http_requests_total is labeled by route, status_code, and region. With 50 route templates, 5 status-code classes, and 3 regions, the number of distinct time series is:
That is a completely reasonable number for a metrics backend to hold. Now suppose someone adds user_id as a label on a service with 2 million active users, keeping the other dimensions:
That single label change turns a 750-series metric into a 1.5-billion-series metric. This is the concrete mechanism behind "cardinality overhead": it is not fuzzy, it is a multiplication, and any unbounded label multiplies the total by its full range. That is why the rule is "never an unbounded value as a label," not "be careful with labels."
Trade-offs & pitfalls
- Waiting for "the right instrumentation plan" before shipping any telemetry is worse than shipping imperfect metrics on day one and iterating. A service with zero observability during its riskiest early weeks is the actual failure mode this question is testing for.
- Over-instrumenting traces early (spanning every function) creates noisy, expensive traces that nobody reads, and by the time someone wants to prune it, dashboards and alerts already depend on the noise.
- Adding a label "just in case it's useful for debugging" is how cardinality incidents happen. If you need per-user detail, get it from logs or traces (where cardinality is expected and priced differently), not from a metric label.
- In a Kubernetes shop specifically, the same sequencing shows up as: define a ServiceMonitor or PodMonitor (Kubernetes custom resources that tell a running Prometheus which pods or services to scrape, and how) with a sane scrape interval (15 to 30 seconds is a common starting point, tighter intervals multiply storage cost across every pod), and scope the Prometheus service account's RBAC (role-based access control: Kubernetes' permission system for which service accounts can read or act on which resources) down to only what it needs to discover and scrape targets, before wiring in log shipping and trace collection as sidecars or DaemonSet agents (a DaemonSet runs exactly one copy of a pod on every node, which is why it's the natural fit for a per-node log or trace collector).
What's the difference between a counter, a gauge, and a histogram (and a summary)? For each type, give a real metric you'd track for an HTTP service and explain how you would aggregate it for a dashboard or an alert.
Sample Answer
Direct answer
A counter only goes up (or resets to zero on a process restart) and is for counting events, like total requests or errors. A gauge holds a point-in-time value that can go up or down, like current queue depth. A histogram and a summary both capture a distribution of observed values, like request latency, so you can compute percentiles, but they differ in where that computation happens: a histogram lets the backend compute percentiles at query time from raw bucket counts, while a summary computes them client-side and ships the already-calculated quantile.
The four types side by side
| Type | Behavior | Example metric for an HTTP service | How you'd aggregate it |
|---|---|---|---|
| Counter | Monotonically increasing, resets to 0 only on process restart | Total requests served, total 5xx errors | rate() or increase() over a window, then sum across instances for a fleet-wide rate |
| Gauge | Arbitrary up/down value at a point in time | Current in-flight requests, connection pool size | Read directly, or average/max/min across instances. Not meaningful to compute a rate of it |
| Histogram | Bucketed counts of observations, exposed as cumulative counters | Request latency, response size | Sum bucket counts across instances first, then compute a percentile from the merged buckets |
| Summary | Client-side quantile calculation shipped as a pre-computed value | Request latency, when you specifically need accurate per-instance quantiles | Cannot be correctly aggregated across instances by averaging the quantiles, only meaningful per-instance |
Aggregation semantics that matter for dashboards versus alerts
- For dashboards: histograms let one query produce fleet-wide p50/p95/p99 by summing buckets across every instance, which is what you want for an aggregate latency panel.
- For alerts: counters (via
rate()) are what you alert on for error-rate thresholds, gauges are what you alert on for instantaneous saturation thresholds like queue depth above N, and histogram-derived percentiles are what you alert on for latency SLOs. - Summaries are the odd one out for fleet-wide alerting, because averaging five instances' p99s is not the fleet's real p99. A single instance handling an unlucky slice of traffic gets diluted by the others and hides inside the average.
Worked example
For a fleet of n instances each exposing a histogram with identical bucket boundaries, the fleet-wide count in bucket le is additive:
Ble=i=1∑nbi,leand the fleet-wide quantile is computed by interpolating within the merged buckets Ble, not by averaging each instance's own quantile. This is exactly why histograms (raw counts, additive) are the right choice for fleet-wide latency, and why summaries (already-computed quantiles, not additive) are not: summation is associative, a pre-computed quantile is not.
Trade-offs and pitfalls
- Using a gauge for something that's really cumulative (like a running error count tracked as a gauge that resets on deploy) loses the ability to compute an accurate rate across restarts. Use a counter and let
rate()handle resets. - Choosing a summary because it's simpler and skipping the bucket-tuning work of a histogram is a common shortcut that quietly breaks fleet-wide percentile dashboards later, once the service scales past one instance.
- Histogram accuracy is bounded by bucket granularity: more buckets means better percentile accuracy but higher cardinality and storage cost per series.
You notice a sudden jump in p95 latency that lines up with a recent deployment of a shared caching library. Walk through how you'd form and test hypotheses safely in production, and what you'd want as both an immediate fix and a longer-term one.
Sample Answer
Treat the deploy correlation as a strong lead, not proof, and confirm it with trace-level evidence (where inside the cache library's calls the extra time is actually going) before acting on it. Test the hypothesis safely by routing a small, bounded slice of traffic to the previous library version behind a flag or canary and comparing p95 between cohorts, rather than doing a blind full rollback or, worse, "trying a fix" directly in full production. Pair an immediate mitigation (rollback or config toggle) with a longer-term fix (patch the library's actual defect and add a performance regression gate so this class of regression is caught before the next release, not after).
Framework
1. Confirm the correlation with evidence, not just timing. Pull traces from before and after the deploy for the affected service and compare span durations specifically inside the cache-library calls (not just overall request time). Look for a new blocking call, a changed serialization path, or a connection-pool change, something concrete that explains the shift, rather than relying on "it lines up with the deploy" alone, since a coincident infra event could produce the same-looking correlation.
2. Form a small number of concrete hypotheses from what the traces show, for example: the library switched to a synchronous/blocking call path, it changed serialization format and increased CPU/GC time, or it changed connection pooling and now contends for connections. Each of these predicts a different span-level signature, which is exactly why step 1 has to come first: the trace tells you which hypothesis to chase.
3. Test in production safely, with a bounded blast radius. Route a small percentage of traffic (behind a feature flag, or a canary deploy of the previous library version) to the old code path and compare p95 between the two cohorts over the same time window. Keep the canary small enough, and keep a fast kill-switch, so a wrong hypothesis doesn't extend the incident.
4. Immediate fix vs. long-term fix. Immediate: roll back the library (or toggle off the specific feature that's causing the regression, if that's narrower than a full rollback) to restore the SLO now. Long-term: patch the actual defect in the library, and add the specific performance check that would have caught this (a load test comparing p95 against the previous release) to the CI/CD pipeline so the same class of regression gets caught pre-deploy next time, not discovered by users.
Worked example
Before trusting a p95 comparison between the canary (old library) and the rest of production (new library), you need enough requests in each cohort that the comparison isn't just noise. As a rule of thumb (not a formal confidence interval, just a floor): a stable percentile estimate wants a reasonable number of samples actually landing at or above that percentile. For p95, that's the top 5% of requests, so targeting roughly 100 tail samples means:
n≥0.05100=2,000 requestsper cohort, as a minimum floor before you'd trust the comparison at all.
If the canary is set to 2% of total traffic, and total traffic is a steady 5,000 req/sec, the canary cohort receives:
0.02×5,000=100 req/secso reaching the n=2,000 floor takes at least:
1002,000=20 secondsof canary traffic, given these specific assumptions (2% canary, 5,000 req/sec total). That's a floor, not a target: in practice you'd run the canary considerably longer than 20 seconds to smooth over normal traffic variance and avoid reacting to a transient blip in either cohort, but the arithmetic tells you the absolute minimum observation window your traffic volume allows, which is a genuinely useful sanity check before declaring "the canary confirms it" too early.
Trade-offs and pitfalls
- Deploy-correlated timing is suggestive, not conclusive, on its own: a coincident capacity change, a traffic pattern shift, or an unrelated dependency issue can produce the same-looking "it started right after the deploy" signal. The trace-level evidence in step 1 is what turns a coincidence into a confirmed cause.
- Testing in production always carries risk, even at small scale: the canary needs an actual kill-switch and tight scoping (a small percentage, ideally excluding your most latency-sensitive customer segment if you can select for that), not just "we'll watch it closely."
- A quick config revert that resolves the symptom without the long-term fix risks the same defect resurfacing on the next deploy, or worse, in a different service that also picks up the same shared library later. The two-tier fix (immediate + long-term) exists specifically to close that gap.
- The n≥2,000 rule of thumb above is a floor for percentile stability, not a substitute for a proper statistical significance test if your organization already has that machinery (paired comparison, confidence intervals on the percentile difference); treat it as "don't trust a comparison with fewer samples than this," not as "this many samples proves significance."
Unlock Full Question Bank
Get access to all 42 Monitoring, Logging, and Observability interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.