Skip to content

Intermediate Level

This section covers intermediate monitoring and logging concepts commonly asked in interviews for experienced professionals.

Monitoring Methodology

0 / 3 reviewed (0%)
  1. What are the RED and USE methods?

    Two structured checklists that prevent "we should probably monitor something" guesswork:

    • RED (for services/requests) — Rate (requests/sec), Errors (failed requests/sec), Duration (latency distribution). Apply per service/endpoint — it's the shape of every good service dashboard
    • USE (for resources/infrastructure) — Utilization (% busy), Saturation (queued work waiting — the leading indicator), Errors (device/system errors). Apply per resource: CPU, memory, disk, network

    The complementary relationship: RED watches the users' experience of services; USE watches the resources they run on. When a RED metric degrades, USE on the underlying resources usually finds the cause. Together with the four golden signals, they're the standard vocabulary for "what do we actually monitor?"

  2. How does alerting work well vs badly (alert fatigue)?

    Alert fatigue — where on-call engineers start ignoring pages — is a process failure with real outage consequences. The design rules:

    • Alert on symptoms, not causes — page on "checkout error rate above SLO", not "CPU is 85%" (CPU spikes self-resolve constantly)
    • Every page must be actionable — "something a human needs to do now"; anything else is a dashboard or a ticket
    • Thresholds with for durations — transient blips don't page (Prometheus for: 5m)
    • Group and dedupe — 40 alerts from one root cause should deliver one notification (Alertmanager group_by)
    • Measure the alerting itself — pages per shift, % of pages actionable, alerts silenced/ignored — and prune ruthlessly

    The maturity marker to state: a healthy system pages rarely, and every page is worth waking someone up. If pages are routinely ignored, the alerting has failed even if every alert "fired correctly".

  3. What is SLO-based alerting (error budgets in alert form)?

    Instead of threshold-on-a-gauge alerts, SLO-based alerting pages on burn rate of the error budget:

    • Your SLO: 99.9% of requests succeed over 30 days → error budget = 0.1% failures
    • Fast burn alert — consuming budget at 14× the sustainable rate over 1 hour → page now (at this pace, the month's budget dies in ~2 hours)
    • Slow burn alert — 3× rate over 6 hours → ticket/alert, fix during business hours
    • Multi-window queries (e.g., 1h and 5m burn rates together) reduce false positives

    Why it's the senior answer: thresholds ask "is this number bad right now?"; burn-rate alerting asks "are we consuming the reliability the business signed up for faster than we can afford?" — it self-tunes to traffic patterns and directly ties paging to the SLO conversation with the business.

Prometheus Questions

0 / 6 reviewed (0%)
  1. What is the difference between the pull and push models?

    • Pull (Prometheus) — the monitor fetches /metrics from targets on a schedule
      • Pros: the monitor controls scrape health (up metric per target), target failure is observable, monitoring infra outages don't lose data silently, and scraping acts as simple load smoothing
      • Cons: short-lived jobs can die between scrapes; NAT/firewall boundaries need the monitor to reach targets
    • Push — targets send metrics to a collector (StatsD, DataDog agent, OTLP)
      • Pros: batch/ephemeral jobs report reliably; works through restrictive network topologies
      • Cons: the monitor can't tell "idle" from "dead"; push floods during outages (thundering herd)

    The complete answer names the hybrid: Prometheus stays pull for services, plus Pushgateway for batch-job metrics (with the caveat that Pushgateway is a cache, not a metrics store — stale pushed metrics persist and need explicit cleanup), and remote_write streams Prometheus data outward to long-term stores (Thanos, Mimir, commercial backends).

  2. What is high cardinality in Prometheus, and why is it dangerous?

    Cardinality = the number of unique label-combination time series a metric produces. Prometheus holds every series in memory — so a metric with user_id as a label doesn't create one series, it creates one per user (millions):

    • Consequences — memory explosion (OOM), slow queries, scrape/TSDB pressure; the failure is often sudden and takes down monitoring precisely when you need it
    • What's safe — bounded labels: service, instance, status code, region, endpoint
    • What's not — unbounded IDs: user_id, session_id, request_id, email, full URLs with query params

    Mitigations: move the detail to logs/traces (which are built for per-request data) and keep metrics aggregated; use histogram buckets for distributions; if you truly need high-cardinality metrics, that's the use case for dedicated stores (Cortex/Mimir with columnar compression, or VictoriaMetrics) rather than vanilla Prometheus.

    The sizing intuition to offer: healthy Prometheus deployments run hundreds of thousands of series; poorly designed ones hit millions and die.

  3. What are recording rules, and why use them?

    Recording rules precompute frequently-used or expensive PromQL expressions into new time series, evaluated continuously:

    yaml
    groups:
      - name: service_slo
        rules:
          - record: job:http_errors:ratio_rate5m
            expr: sum(rate(http_requests_total{status=~"5.."}[5m])) by (job)
                  / sum(rate(http_requests_total[5m])) by (job)
    • Dashboard performance — panels query the precomputed series (milliseconds) instead of re-aggregating raw data (seconds) on every refresh
    • Reusable SLO metrics — the burn-rate alert queries the recorded series consistently across services
    • Naming convention — level:metric:operations (e.g., job:http_errors:ratio_rate5m) is the community convention and makes rule outputs self-describing

    Also worth naming: alerting rules sit in the same rule groups, evaluated on the same schedule — and rule evaluation cost is part of Prometheus's own resource budget (visible in its self-metrics).

  4. What is Thanos (and Cortex/Mimir), and when do you need them?

    Prometheus is single-node by design — local storage, local retention. The "horizontal layer" projects extend it:

    • Thanos — sidecars upload Prometheus TSDB blocks to object storage (S3); a query layer fans out across all Prometheus instances and deduplicates HA replicas; compaction and downsampling run against object storage
    • Cortex / Grafana Mimir — horizontally-scalable Prometheus-compatible backends: many Prometheus servers remote_write into a clustered store with multi-tenancy built in
    • VictoriaMetrics — a popular high-performance alternative backend

    When you need them, concretely: retention beyond a couple of weeks, more than ~10-20 Prometheus servers, global queries across clusters/regions, or HA deduplication. Below that, two HA Prometheus replicas with different retention are simpler and perfectly adequate — the projects have real operational cost, so the "when" matters.

  5. How do you achieve Prometheus high availability?

    • Run redundant replicas — two (or three) identical Prometheus instances scraping the same targets with the same rules; each fires its own alerts
    • Deduplicate alerts — Alertmanager clusters handle it: replicas send to the same Alertmanager cluster, which deduplicates and pages once
    • Deduplicate queries — if both replicas serve dashboards, Thanos/Mimir query-layer dedup collapses the two series into one
    • Shard for scale — split scrape targets (by service or hashmod) across Prometheus servers; a global query layer unions them
    • Data durability — remote_write to object-storage backends (Thanos/Mimir), since a single Prometheus loses recent data on node loss (the WAL covers crashes, not dead nodes)

    The architecture summary: HA Prometheus = N identical replicas + Alertmanager cluster for dedup + a long-term store for retention and global queries.

  6. How do you monitor Kubernetes with Prometheus?

    The standard stack is kube-prometheus-stack (Prometheus Operator Helm chart), which wires everything together:

    • Prometheus Operator — manages Prometheus instances/alert rules as CRDs (Prometheus, ServiceMonitor, PrometheusRule) — config as code
    • Metrics sources — kubelet/cAdvisor (container metrics), kube-state-metrics (object state: deployments, pods, replicas), node-exporter (host metrics)
    • Grafana — ships with community dashboards for cluster/node/pod views (IDs 315, 1860 — worth knowing)
    • ServiceMonitors — the CRD that declares which pods to scrape, selected by labels; pods expose /metrics and get discovered automatically

    The interview depth: explain that the Operator pattern turns monitoring config into declarative YAML reviewed in Git — adding a ServiceMonitor to a repo is how a new service gets scraped, not editing Prometheus config by hand.

Grafana & Loki Questions

0 / 3 reviewed (0%)
  1. What is Grafana Loki, and how is it different from Elasticsearch?

    Loki is Grafana's log aggregation system — designed around a fundamentally different indexing philosophy:

    AspectLokiElasticsearch
    IndexingIndexes only labels (metadata), not log contentFull inverted index over every token
    Storage costMuch lower (compressed chunks, tiny index)High (full-text index dominates)
    Query modelLogQL: label-select chunks, then filter contentRich DSL over indexed fields
    Full-text searchSlower (scan-after-select)Fast — the core strength
    Kubernetes fitExcellent (label model mirrors K8s, Promtail/Alloy)Heavier resource footprint

    The design philosophy to state: Loki is "Prometheus for logs" — the same label-based model, so you correlate logs and metrics with identical selectors ({job="api"} |= "error" next to the matching PromQL). Choose Loki for cost-efficient, label-centric K8s logging; choose Elasticsearch when full-text search and complex aggregations are the actual requirement.

  2. How do logs get into Loki (Promtail/Alloy), and how do you query LogQL?

    • Promtail (classic agent) — tails files/container logs, attaches labels (pod, namespace, job from K8s metadata), ships to Loki. Deprecation note: it's being succeeded by Grafana Alloy (the unified OTel-based collector)
    • Collection modes — DaemonSet per node (recommended: one agent sees all pods on the node) or sidecars per pod
    text
    # All logs from one service in the last hour, filtered
    {job="api"} |= "timeout" | logfmt
    
    # Count error lines per pod — metrics FROM logs
    sum by (pod) (count_over_time({job="api"} |= "ERROR" [5m]))
    
    # Extract a field and compute on it
    {job="api"} | json | status >= 500 | rate [5m]

    The LogQL superpower to highlight: log-to-metric queries (count_over_time, bytes_over_time) — you can build error-rate dashboards and alerts directly from logs without instrumenting new metrics.

  3. How do you provision and scale Grafana for teams?

    • Provisioning as code — data sources, dashboards, and alert rules from YAML files/CRDs on startup (no click-ops); dashboards as JSON in Git; the Grafana Operator for K8s-native management
    • Auth at scale — SSO via OAuth/OIDC/SAML (team membership from identity-provider groups), LDAP for legacy; service accounts for automation tokens
    • Multi-tenancy options — folders + folder permissions per team; organizations (heavier separation); or separate Grafana instances per business unit; data-source permissions restrict what each team can query
    • Performance — query caching, dashboard JSON to keep panels lean, and alerting moved to Grafana's unified alerting (or left in Prometheus/Alertmanager — pick one home to avoid duplicate pages)

    The maturity marker: a new team gets monitoring by adding YAML to Git — data source, folders, and baseline dashboards appear without manual UI work.

ELK/Elasticsearch Questions

0 / 4 reviewed (0%)
  1. What are Elasticsearch shards, and how do you size them?

    An index splits into primary shards (each an independent Lucene index holding part of the data) distributed across nodes; replica shards are copies for redundancy and read scaling:

    json
    PUT /logs-2024.06
    {
      "settings": { "number_of_shards": 3, "number_of_replicas": 1 }
    }

    The sizing wisdom (where ELK clusters actually succeed or fail):

    • Shards have fixed overhead — each one consumes heap and file handles regardless of size; too many tiny shards ("oversharding") is the #1 ELK cluster killer
    • Target shard size — roughly 20–50 GB per shard as a working heuristic
    • Time-based indices — one index per day/week (e.g., logs-2024.06.11) so retention = deleting old indices (instant, cheap) rather than reindexing
    • Replicas — 1 replica for redundancy in prod (0 acceptable for ephemeral log data with external backups); queries scale reads across primaries+replicas
    • Shard count is fixed at index creation — plan per index, not per cluster, since time-based indices roll constantly
  2. What is Index Lifecycle Management (ILM), and how do you configure it?

    ILM automates an index's lifetime through phases — the retention engine for time-series logs:

    • Hot — actively written and queried (SSD nodes); rollover when size/age threshold hits (e.g., 50GB or 1 day)
    • Warm — no longer written, occasionally queried; move to cheaper nodes, shrink/force-merge segments (merge to 1 segment saves heap)
    • Cold — rarely accessed; searchable cold storage / frozen tier on even cheaper infrastructure
    • Delete — remove after the retention window (e.g., 90 days)
    json
    { "policy": { "phases": {
        "hot":    { "actions": { "rollover": { "max_size": "50gb", "max_age": "1d" } } },
        "warm":   { "min_age": "7d",  "actions": { "forcemerge": { "max_num_segments": 1 } } },
        "delete": { "min_age": "90d" }
    } } }

    The operational value: retention becomes policy, not cron scripts — and storage cost drops by tiers instead of being uniformly expensive. Pair with data streams (the modern index-rollover abstraction) so apps write to one name forever.

  3. How do you tune Elasticsearch for heavy log indexing?

    Ingest-heavy clusters (thousands of logs/sec) fail in predictable ways — tune accordingly:

    • Bulk sizing — index in bulk requests (~5–15 MB each), not one document at a time; Filebeat/Logstash handle this if queues are sized right
    • Refresh interval — logs don't need instant searchability: index.refresh_interval: 30s (default 1s) dramatically reduces indexing load
    • Shard count — avoid oversharding (each shard is a Lucene index with heap cost); one shard per ~20–50GB per rollover period
    • Mappings — disable features you don't use: index: false on fields you never search, don't index high-cardinality IDs, use text+keyword deliberately; eager global ordinals off for keyword fields
    • Merge and translog — tune index.translog.durability: async (accept small loss on crash for throughput), let ILM forcemerge control segment sprawl
    • Queues for bursts — Logstash persistent queues / Kafka between shipper and ES absorb spikes instead of dropping logs

    The symptom-to-fix pattern: "indexing latency high / bulk rejections (429)" → too many shards, too-frequent refresh, or undersized ingest nodes.

  4. How do you secure Elasticsearch and Kibana?

    • Security on — xpack.security.enabled: true (default in recent versions); TLS on the HTTP layer and between nodes (transport layer)
    • Authentication — native users with roles, API keys for services (scoped, expiring), or SSO/LDAP/OIDC via Kibana; service accounts for machine access
    • Authorization — role-based index/document-level permissions: a team reads only its own indices; Kibana users see only permitted spaces
    • Network — clusters never exposed to the internet; firewall/security-group restriction to the application/collector network; Kibana behind SSO with IP allowlisting
    • Audit + data protection — audit logging enabled (who queried what), encryption at rest on the data volumes, field/document-level security for sensitive logs (PII scrubbing at ingest is even better)

    The compliance tie-in: log data is frequently regulated data — access control, retention, and audit on the logging stack are often audited themselves.

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