Advanced Level
This section covers expert-level monitoring and logging concepts commonly asked in interviews for senior professionals.
Prometheus at Scale
How do you scale Prometheus for a large, multi-cluster environment?
Prometheus is single-node by design — scale by decomposing:
- Split by function — separate Prometheus servers per cluster/team/region, each scraping a shard of targets (path filters, hashmod sharding on a label)
- Federation — a top-level Prometheus scrapes aggregated series (
/federate) from child servers — good for a global overview, not for raw high-cardinality data - Long-term storage — Thanos sidecars (blocks to object storage + global query + dedup) or remote_write into Mimir/Cortex (horizontally scalable, multi-tenant) or VictoriaMetrics (high compression, single-binary options)
- The receiver pattern — Mimir/Loki-style: agents remote_write to a scalable cluster; query there instead of fanning out per-server
The sizing rules to state: one Prometheus comfortably handles roughly ~1–5 million active series and 15s scrapes on decent hardware (memory is the binding constraint); beyond that, shard. And decide retention deliberately: 15d local + 13mo in object storage is a common, cost-sane split.
How does Prometheus handle missing, stale, or dead targets?
Four mechanisms, each for a different failure mode:
upmetric — every scrape setsup{job,instance}to 1 or 0; the simplest health signal (up == 0for 5m = target down)- Stale markers — when a target disappears from discovery (pod deleted), Prometheus writes staleness markers so its series stop matching queries instantly — preventing "frozen last value" lies
absent()/absent_over_time()— for series that simply never appear (a process that never started, a job that stopped exporting):absent(up{job="critical-service"})fires when the series is missing entirely — the alert for "the thing that was supposed to report isn't reporting"- Dead man's switch — the inverse watch: a always-firing
Watchdogalert routed to an external heartbeater (PagerDuty heartbeat, healthchecks.io); if the heartbeat stops, the external system pages — catching the worst failure mode: Prometheus itself being down, which Prometheus cannot alert on by definition
The senior insight: absent() + watchdog alerts close the "monitoring the monitor" gap — the most commonly missed layer in self-managed stacks.
What is the Prometheus WAL and TSDB, and how do you operate them?
- WAL (write-ahead log) — incoming samples append to WAL files (
data/wal/) before being persisted into 2-hour TSDB blocks; on crash, Prometheus replays the WAL — covering the gap between memory and durable blocks. Checkpoints every 2 hours trim it - TSDB blocks — immutable, compressed chunks (2h each) with an index; old blocks compact and (with Thanos/Mimir) upload to object storage
Operationally:
- Disk headroom — WAL replay after a crash is I/O-heavy; keep headroom and never run Prometheus on slow disks
- The classic incident — unclean shutdown → long WAL replay → monitoring "down" for many minutes; mitigated by frequent block persistence (2h default) and, for HA, redundant replicas
- Retention —
--storage.tsdb.retention.timegoverns local blocks; compaction merges 2h blocks upward; corruption issues surface at startup — knowtsdb-util/backup strategies or push to remote storage so local loss isn't fatal
- WAL (write-ahead log) — incoming samples append to WAL files (
Histograms vs summaries in Prometheus — how do you choose?
Both measure distributions (latency, sizes), and the difference determines whether you can aggregate across instances:
- Histogram — client counts samples into predefined buckets (
le="0.1",le="0.5"...). Server-side quantiles computed viahistogram_quantile()— aggregatable across all instances:Costs: bucket config is fixed at instrument time; quantiles are approximations of bucket boundariestext - Summary — client computes exact quantiles (φ-quantiles like p95) itself via streaming. Accurate per-instance, but cannot be aggregated —
avgof two summaries' p95 is mathematically meaningless - Client cost — summaries do the math on every observation; histograms are cheaper but produce more series (one per bucket)
The rule to state: histograms by default in distributed systems (the p95 across your fleet matters, not per-instance); summaries only for single-instance exact quantiles. Also name the unit discipline: seconds (base units) in
http_request_duration_seconds, and consistent buckets across services so percentile aggregation is valid.- Histogram — client counts samples into predefined buckets (
How do you secure Prometheus and its endpoints?
- The exposed-metrics reality —
/metricsoften leaks internal topology, versions, and sometimes secrets-bearing labels. Prometheus itself has no built-in auth — harden the perimeter:- Network — scrape traffic on a private network; Prometheus reachable only from dashboards/jump hosts; NetworkPolicies in K8s
- Reverse proxy — basic auth/OAuth/TLS in front of Prometheus and exporters (nginx, Traefik), or the
web.config.fileTLS/basic-auth support
- Federation/remote_write — TLS + auth on every remote endpoint (
--web.config.filewith TLS client certs) - Kubernetes — NetworkPolicies restricting scrape sources; RBAC on the Prometheus Operator CRDs; secrets (
bearer_token_file) for scrape auth - What metrics leak — audit exported paths (
/metricsof your apps), scrub sensitive labels at instrument time, and remember Alertmanager webhooks also carry data
The design question to anticipate: "who else can read our metrics?" — metrics reveal business volume (sales/sec), topology, and error patterns; treat them like semi-internal data.
- The exposed-metrics reality —
How do you monitor Prometheus itself (meta-monitoring)?
The monitoring system is itself critical infrastructure — monitor it with the same rigor:
- Self-metrics — Prometheus exposes its own
/metrics: scrape health (prometheus_tsdb_head_seriescardinality,prometheus_target_interval_length_secondsscrape jitter), rule evaluation cost, WAL/compaction health - Key health signals — head series count trend (cardinality creep — the slow OOM), scrape duration vs interval (targets timing out), rule group evaluation duration, remote_write queue failures (data silently lost)
- Dashboards + alerts — the community Prometheus-self dashboard; alert on: high cardinality growth rate, evaluation failures,
prometheus_config_last_reload_successful == 0, disk filling - The second level — a separate lightweight Prometheus (or an external synthetics service) watching the main one, plus the dead man's switch (Watchdog → external heartbeat) covering total monitoring failure — the failure main Prometheus can never self-report
The architecture summary: meta-monitoring + watchdog = you learn about monitoring failures before users report blindness during an incident.
- Self-metrics — Prometheus exposes its own
Grafana & Loki Questions
How does Grafana unified alerting work, and how do you design alert routing?
Grafana 9+ unified alerting brings alert rules (for Prometheus, Loki, and other sources) into one engine:
- Rule anatomy — query + expression → condition → evaluation interval → contact point → notification policy (routing by labels)
- States — Normal → Pending (condition met, within
for) → Alerting → (resolved) — withNoData/Errorstates to handle explicitly (a "No Data" alerting rule catches broken queries) - Routing — labels route to contact points (Slack, PagerDuty, webhooks):
severity=critical+team=payments→ payments' PagerDuty; nested policies allow team-scoped sub-routes - Silences/maintenance — time-bounded silences for deploys; MuteTimings for recurring windows
The design guidance: decide the single home for alerting (Alertmanager OR Grafana — running both duplicates pages), route by labels not per-alert config, and version alert rules as code (files/CRDs) like everything else.
How do Grafana annotations and on-call workflows connect dashboards to incidents?
- Annotations — vertical event markers on every time-series graph: deployments, incidents start/end, config changes. Automatically added via API from CI/CD (
curla POST on deploy) — so every dashboard shows "the error rate spiked exactly when build #4711 shipped" - The debugging acceleration — correlation without cross-referencing: an engineer opens the dashboard, sees the annotation line at the inflection point, and starts with the right change
- Grafana OnCall — escalation chains, on-call schedules, and incident objects integrated beside dashboards; or feed annotations into/out of PagerDuty/Opsgenie
- Automation to mention — annotations from deployments (CI), from alerts (Alertmanager), from chaos experiments (each experiment marks the timeline)
The cultural point: annotation-augmented dashboards change post-incident review quality — "what changed?" is answered visually, instantly, and without tribal memory.
- Annotations — vertical event markers on every time-series graph: deployments, incidents start/end, config changes. Automatically added via API from CI/CD (
How do you run Grafana and Loki in multi-tenant, multi-team setups?
- Tenancy models — folders + permissions (teams see their dashboards), organizations (harder separation), or separate stacks per business unit; Grafana Cloud/Mimir/Loki Enterprise bring native per-tenant isolation via
X-Scope-OrgID - Data-source isolation — per-team data sources with permissions; in multi-tenant Loki/Mimir, tenants share infrastructure but never see each other's data
- Provisioning at fleet scale — everything as YAML/CRDs; golden dashboards templated per service; teams extend rather than fork (or dashboards fork and drift)
- Resource governance — Loki per-tenant stream/ingest limits (one noisy tenant can degrade shared Loki), Grafana query concurrency/timeout limits, alert-rule evaluation caps
The scaling insight to deliver: multi-tenancy failures in monitoring are shared-fate failures — one team's cardinality explosion or heavy dashboard query degrades everyone's visibility, so per-tenant limits and isolation are reliability features, not niceties.
- Tenancy models — folders + permissions (teams see their dashboards), organizations (harder separation), or separate stacks per business unit; Grafana Cloud/Mimir/Loki Enterprise bring native per-tenant isolation via
Elasticsearch & OpenTelemetry Questions
What is the hot-warm-cold architecture in Elasticsearch, and how do you implement it?
The tiered-data strategy: logs age from expensive to cheap infrastructure as access frequency drops:
- Hot nodes — NVMe/SSD, high memory; actively written and queried (today's indices);
data_hotrole - Warm nodes — cheaper storage; older indices still queried occasionally;
data_warm, forcemerged single-segment indices - Cold/frozen — searchable snapshots on object storage (S3); queryable but slow to restore;
data_cold/data_frozen - ILM wires the movement —
allocateactions move indices by age (min_age: 7d→ warm,30d→ cold,90d→ delete), using index templates to assign ILM policies automatically
The cost math to state: hot storage is often 5–10× the cost of cold — tiering cuts the logging bill dramatically while keeping the retention window auditors ask for. Requirement to mention: dedicated tier node roles and ILM policies are part of cluster setup from day one — retrofitting tiers onto an over-sharded cluster is painful.
- Hot nodes — NVMe/SSD, high memory; actively written and queried (today's indices);
How does Logstash handle backpressure and reliability (persistent queues, DLQ)?
The pipeline between shippers and Elasticsearch must survive ES outages and spikes without losing logs:
- Persistent queues —
queue.type: persistedwrites events to disk before processing: an ES outage becomes "Logstash buffers" instead of "logs lost";queue.max_bytesbounds disk usage — when full, backpressure propagates to inputs (Beats retry) - Dead letter queues (DLQ) — events rejected by Elasticsearch (mapping conflicts, malformed docs) route to a DLQ file for reprocessing instead of vanishing
- Ack/retry chain — Filebeat → Logstash → ES: each hop acknowledges; failures retry with backoff; Beasts keep a registry of shipped offsets
- The alternative topology — Kafka between shippers and Logstash (or ES ingest): Kafka is the buffer — better for extreme scale and multi-consumer fan-out; Logstash then becomes a consumer group member
The design question to anticipate: "what happens to logs during a 2-hour Elasticsearch outage?" — with persistent queues sized correctly: delayed, not lost. That answer separates designed pipelines from default configs.
- Persistent queues —
How do you manage Elasticsearch query performance and caching?
- Shard request cache — caches shard-level results for frequently-run identical queries; effective for dashboard time-windows on immutable (rolled-over) indices — size via
indices.requests.cache.size - OS page cache — the real workhorse: Lucene reads from the filesystem cache; more RAM (beyond JVM heap) = faster queries; keep heap ≤ ~50% of RAM, leave the rest to the OS cache
- Query hygiene — avoid leading wildcards (
*error*scans everything), prefertermovermatchfor keywords, use date-scoped queries (narrow indices via aliases), and paginate withsearch_afternot deepfrom/size - Doc values / fielddata — sorting/aggregations read doc values (columnar, on disk) by default; enabling
fielddataon text fields loads them into heap — the classic OOM mistake - Instrumentation — slow query logs (
index.search.slowlog) expose the offending dashboards/queries; profile API for deep dives
The operation pattern: dashboards drive most load — tune the queries dashboards run (recorded ranges, fixed intervals, cached aggregations) before scaling the cluster.
- Shard request cache — caches shard-level results for frequently-run identical queries; effective for dashboard time-windows on immutable (rolled-over) indices — size via
How does Kibana's ML-based anomaly detection work?
Elastic's machine-learning features (X-Pack ML) run unsupervised models over your data to detect anomalies without hand-written thresholds:
- Data frames + detectors — a job defines functions over fields in buckets (
mean(cpu_usage)per 15m bucket) over a training window; the model learns normal behavior per entity (per-server, per-service) including seasonality (daily/weekly cycles) - Anomaly scores — each bucket gets a probability-based score; unusual values (a traffic spike at 3 a.m., a normally-quiet endpoint erroring) surface with influential contributors
- Feeds into alerting — ML results trigger watcher/Kibana rules ("anomaly score > 90 on checkout latency") — catching previously-unknown failure modes threshold alerts miss
- SIEM layer — the Kibana Security/SIEM app applies the same ML to security event streams (impossible travel, rare processes) plus detection rules
The honest framing to include: ML detects novel anomalies that fixed thresholds can't — but it also produces false positives during legitimate behavior changes (deploys, marketing spikes), so baselines need retraining windows and the alert routing needs the same fatigue discipline as threshold alerting.
- Data frames + detectors — a job defines functions over fields in buckets (
What is OpenTelemetry, and how does it change the observability stack?
OpenTelemetry (OTel) is the vendor-neutral standard for emitting metrics, logs, and traces — SDKs/APIs for instrumenting code, plus the Collector: a deployable pipeline (agent per node + central gateway) that receives (OTLP, and legacy formats), processes (filter, sample, redact, enrich), and exports to any backend:
- The problem it solves — instrumentation lock-in: code instrumented once (OTel SDK, or zero-code auto-instrumentation agents for Java/Python/Node/.NET) exports to Prometheus, Datadog, Elastic, Grafana — switching backends doesn't mean re-instrumenting the fleet
- Collector as the pipeline — the single place for log/metric/trace processing that Logstash-style tools used to own: tail-based sampling (keep all error traces, 1% of healthy ones), PII scrubbing, k8s metadata enrichment, multi-backend fan-out
- Semantic conventions — standardized names/attributes (
http.request.duration,service.name) so dashboards and queries work across services and languages - The architecture pattern — app → OTel agent (sidecar/DaemonSet) → OTel gateway (central collector) → backends; traces/metrics/logs flowing through one pipeline with consistent correlation IDs
The strategic answer to give: OTel is to observability what Terraform is to infrastructure — an abstraction layer that makes the backend a decision you can revisit. New instrumentation should be OTel-first; legacy agents (Promtail, Beats, StatsD) get replaced at the collector boundary.
How do you control the cost of an observability stack at scale?
Observability is often the most expensive "supporting" platform — and its costs are controllable with deliberate policy:
- Metrics — cardinality governance (label allowlists in instrumentation review, card-buffer alerts in Prometheus), scrape interval tuning (30s for low-value targets), recording rules + downsampling for old data, retention tiers (15d hot, 13mo cold object storage)
- Logs — tiered retention (hot 7–14d, cold to cheap storage), structured logging with
level-based routing (debug logs opt-in per service, sampled), drop/filter noisy events at the collector (health-check spam), volume quotas per team - Traces — head or tail-based sampling (keep 100% of errors/slow traces, sample the rest — tail sampling at the OTel collector), short hot retention
- Backends — the tier decision (Loki vs Elasticsearch, Mimir vs vanilla Prometheus) is a cost decision; object-storage backends separate compute from storage growth
- Governance — per-team dashboards of their own observability spend; ingestion limits enforced at the collector (a runaway debug log is an outage of the logging platform itself)
The line that lands: observability cost scales with retention × cardinality × verbosity — set all three deliberately per data class, instead of paying default-everything forever.
Contribute & Stay Updated
Want to contribute? We welcome contributions! If you have insights, new tools, or improvements, feel free to submit a pull request.
How to Contribute?
- Read the CONTRIBUTING.md guide.
- Fix errors, add missing topics, or suggest improvements.
- Submit a pull request with your updates.
Community & Support
GitHub: @NotHarshhaa Blog: ProDevOpsGuy Telegram Community: Join Here