Advanced Prometheus Interview Questions: Internals (2027)

46 advanced Prometheus interview questions on TSDB, WAL, compaction, cardinality, remote write, native histograms, HA, Thanos and Mimir.

Sep 13, 2025 - 14:20
Nov 8, 2026 - 17:58
 0  106
Advanced Prometheus Interview Questions: Internals (2027)

Advanced Prometheus interview questions test how the server works inside and how it behaves at scale: the TSDB head block, WAL and compaction, cardinality limits, remote write tuning, native histograms, high availability pairs, sharding, agent mode and long-term storage with Thanos, Cortex or Mimir. This page has 46 architect-level questions with direct answers.

This is the deep-dive page in our Prometheus series. If you need the basics first, start with the 80+ Prometheus interview questions guide. For hands-on query drills, use the Prometheus engineer PromQL tasks, and for troubleshooting stories, the scenario-based Prometheus questions. The questions below go one level lower: why the server does what it does. Facts were checked against the prometheus.io documentation in November 2026.

Key takeaways

  • Prometheus groups samples into two-hour blocks. The newest data lives in an in-memory head block protected by a write-ahead log stored in 128MB segments.
  • Compaction merges blocks up to 10% of the retention time or 31 days, whichever is smaller. Default retention is 15 days when no time or size limit is set.
  • Memory use follows active series count, so cardinality control (sample_limit, label_limit, relabeling) is the main scaling lever.
  • Native histograms are stable from Prometheus v3.8.0. From v3.9 you must set scrape_native_histograms explicitly; the feature flag is a no-op.
  • Remote write has a stable 1.0 spec and an experimental 2.0 spec, selected with protobuf_message.
  • Prometheus itself is a single-node database. Global views and long retention come from Thanos, Cortex or Grafana Mimir, or from federation for small aggregates.

Who this page is for

Senior DevOps engineers, SREs and platform engineers interviewing for roles where they will own a monitoring platform, not just write dashboards. Interviewers at this level expect you to reason about disk, memory and network costs, and to explain trade-offs between designs.

TopicQuestionsWhat the interviewer checks
TSDB internals1 to 10Head block, WAL, compaction, retention, out-of-order data
Cardinality and limits11 to 17Memory model, scrape limits, relabeling cost
Native histograms and exemplars18 to 22Schema, buckets, migration from classic histograms
Remote write and agent mode23 to 29Queue tuning, protocol versions, agent trade-offs
HA, sharding and long-term storage30 to 38Federation, Thanos, Cortex, Mimir, deduplication
Rules, security and operations39 to 42Rule evaluation at scale, TLS, auth
Architecture scenarios43 to 46Whiteboard design questions

TSDB internals (2-5 years)

1. How does Prometheus store samples on disk?

Samples are grouped into blocks that each cover two hours. Each block is a directory holding chunk files, an index, a metadata file and an optional tombstones file for deletions. The current two-hour window is kept in memory in the head block and written to the wal directory so it survives a crash. Older blocks are immutable.

2. What is the head block?

The head block is the in-memory part of the TSDB that receives new samples. It holds the active series, their labels and the open chunks. Full chunks are memory-mapped from the chunks_head directory to reduce resident memory. When the head covers enough time, Prometheus cuts a persistent two-hour block from it.

3. What does the WAL do, and how big are its segments?

The write-ahead log records every incoming sample before it is acknowledged, so the head block can be rebuilt after a restart. It is stored in 128MB segments. Prometheus keeps at least three segment files, and busy servers keep more so that two hours of raw data are covered. WAL compression has been on by default since 2.20.0.

4. Why does Prometheus sometimes take minutes to start?

On startup it replays the WAL to rebuild the head block. The more series and the longer the unflushed window, the longer the replay. Memory-mapped head chunks and WAL checkpoints shorten it, but a server with millions of active series can still need minutes before /-/ready returns success. Plan readiness probes and rollout timeouts around this.

5. What is a WAL checkpoint?

When old WAL segments are truncated after a block is cut, Prometheus writes a checkpoint that keeps only the records still needed (for example series that are still active). This keeps replay time bounded instead of reading every historical segment.

6. How does compaction work?

Background compaction merges smaller blocks into larger ones and applies tombstones. Compacted blocks can cover up to 10% of the retention time or 31 days, whichever is smaller. Larger blocks mean fewer index lookups for long-range queries.

7. How do time and size retention interact?

--storage.tsdb.retention.time defaults to 15d if neither limit is set. --storage.tsdb.retention.size is disabled by default. If both are set, whichever triggers first wins. Size retention counts the WAL and memory-mapped chunks but only deletes whole persistent blocks, so the docs recommend setting it to no more than 80 to 85% of the disk.

prometheus \
  --storage.tsdb.path=/prometheus \
  --storage.tsdb.retention.time=30d \
  --storage.tsdb.retention.size=400GB

8. Why is disk usage spiky every two hours?

The wal and chunks_head directories peak just before a block is cut, roughly every two hours. Size disk for that combined peak, not for the average.

9. Can Prometheus accept out-of-order samples?

Yes, if you set out_of_order_time_window in the storage.tsdb section of the config. The default is 0s, which rejects samples older than the head's latest time for a series. A window helps when samples arrive late through remote write or from agents with clock or network delays, at the cost of extra memory and compaction work.

storage:
  tsdb:
    out_of_order_time_window: 30m

10. Is local storage suitable for durable, clustered storage?

No. The docs describe local storage as limited to a single node and not clustered or replicated. Treat it as a cache of recent data, take snapshots if you need backups, and use remote storage for durability across failures.

Cardinality and limits (2-5 years)

11. Why does memory follow series count rather than sample rate?

Each active series carries its label set, index entries and at least one open chunk in the head. Doubling the scrape rate adds samples to existing chunks, which compress well. Doubling the series count adds a full set of per-series overhead. That is why one new label with a user ID can exhaust memory while a faster scrape interval barely moves it.

12. What is series churn and why does it hurt?

Churn is series appearing and disappearing, for example a pod label changing on every deployment. Old series stay in the head until the next block cut and stay in the index for the block's lifetime. High churn inflates memory and index size even if the number of series at any moment looks normal.

13. Which scrape limits protect the server from a bad target?

sample_limit caps samples per scrape, label_limit caps labels per sample, and target_limit (experimental) caps targets per scrape config. All default to 0, meaning no limit. When a scrape exceeds sample_limit, the whole scrape fails, which shows up as up == 0 for that target.

scrape_configs:
  - job_name: app
    sample_limit: 50000
    label_limit: 30
    target_limit: 500

14. What is the difference in cost between relabel_configs and metric_relabel_configs?

relabel_configs runs on targets before the scrape, once per target per discovery update, so it is cheap. metric_relabel_configs runs on every scraped sample after the scrape, so it costs CPU on each scrape. Prefer to fix noisy metrics at the source; use metric relabeling to drop what you cannot change.

15. What does keep_dropped_targets do?

It limits how many targets dropped by relabeling are kept in memory for display on the service discovery page. In large Kubernetes clusters, keeping every dropped target can use noticeable memory, so set a limit.

16. Which TSDB metrics show cardinality pressure?

prometheus_tsdb_head_series gives active series, prometheus_tsdb_head_series_created_total shows churn, and scrape_series_added per target shows who is adding new series. The TSDB status page in the web UI lists the label names and metric names with the most series.

17. How does UTF-8 metric naming in Prometheus 3 affect cardinality work?

Prometheus 3 validates names with the utf8 scheme by default (metric_name_validation_scheme), so names with dots, common in OpenTelemetry, are kept as they are. That means OTel and classic names for the same thing can coexist as separate series. Standardize on one naming path per signal to avoid doubling series.

Native histograms and exemplars (senior)

18. What problem do native histograms solve?

Classic histograms create one series per bucket plus _sum and _count, with fixed boundaries you choose upfront. A native histogram stores all buckets in a single series with exponential boundaries, so resolution is higher and series count is lower. Quantile estimates are more accurate without guessing bucket boundaries.

19. Are native histograms production ready?

The specification says they are stable starting with v3.8.0, after first appearing as experimental in v2.40.0. From v3.9 the old feature flag is a no-op and you must set scrape_native_histograms explicitly.

global:
  scrape_native_histograms: true

20. What is the schema of a native histogram?

The schema sets bucket resolution. Valid standard values are -4 through +8; higher numbers mean finer buckets. Schema -53 is reserved for custom bucket boundaries. Client libraries such as Go use a bucket factor (default 1.1 for NativeHistogramBucketFactor), which maps to schema 3.

21. How do you migrate dashboards from classic to native histograms?

Expose both formats during a transition so old queries using _bucket series keep working while new queries use histogram_quantile() on the native series directly, without the le label. Check that remote storage supports native histograms before switching, and enable send_native_histograms on Remote Write 1.0 queues.

22. What are exemplars and how do they reach remote storage?

Exemplars attach a sample's trace ID to a metric observation, so you can jump from a latency spike to a trace. Exemplar storage must be enabled for them to be scraped, and send_exemplars: true (default false) sends them over remote write.

Remote write and agent mode (senior)

23. How does the remote write queue work?

Prometheus reads samples from the WAL and pushes them through shards, which are parallel senders. Each shard batches samples and sends snappy-compressed protobuf over HTTP. If the endpoint slows down, Prometheus adds shards up to max_shards; if it falls far behind, data waits in the WAL.

24. What are the queue_config defaults?

FieldDefaultEffect
capacity10000Samples buffered per shard
max_shards50Upper bound on parallel senders
min_shards1Shards at startup
max_samples_per_send2000Batch size per request
batch_send_deadline5sMax wait before sending a partial batch

25. How do you tell that remote write is falling behind?

Compare the highest timestamp written to the WAL with the highest timestamp sent, using metrics such as prometheus_remote_storage_queue_highest_sent_timestamp_seconds. Also watch failed and retried sample counters and the desired versus current shard count. If desired shards stays at max_shards, the receiver or network is the bottleneck.

26. What is the difference between Remote Write 1.0 and 2.0?

1.0 is the stable spec and uses the prometheus.WriteRequest message. 2.0 is experimental and uses io.prometheus.write.v2.Request, which adds string interning and native support for metadata, exemplars and histograms. You choose with protobuf_message; the receiver must support the same version.

remote_write:
  - url: https://metrics.example.internal/api/v1/write
    protobuf_message: prometheus.WriteRequest
    write_relabel_configs:
      - source_labels: [__name__]
        regex: "go_gc_.*"
        action: drop
    queue_config:
      max_shards: 100
      max_samples_per_send: 5000

27. Where do write_relabel_configs run?

After external labels are applied and before samples leave the server. They change only what is sent remotely; local storage keeps everything. Use them to cut remote storage cost without losing local detail.

28. What is agent mode and what does it give up?

Agent mode runs Prometheus as a scraper that forwards everything through remote write. It keeps only a WAL, has no local querying, no alerting or recording rules, and no long-term local blocks. It suits edge clusters that send to a central store. In Prometheus 3 it is started with the --agent flag.

29. Can Prometheus receive remote write itself?

Yes. Start it with --web.enable-remote-write-receiver and it accepts writes at /api/v1/write. This is handy for agent-to-server setups in small environments, but a single receiving Prometheus is still one node with local storage limits.

HA, sharding and long-term storage (senior)

30. How do you run Prometheus in high availability?

Run two or more identical servers scraping the same targets with the same rules, each with a distinct replica external label. Both send alerts to a clustered Alertmanager, which deduplicates notifications. Queries need a layer that deduplicates the replicas, such as Thanos Query or a Cortex/Mimir HA tracker; otherwise you pick one replica and accept gaps during its restarts.

31. Why do the two replicas show slightly different values?

They scrape at different moments, so samples are offset in time and counter rates differ a little. That is expected. Deduplication layers choose one replica per time range instead of averaging.

32. How does hashmod sharding work?

Each server hashes a target label (usually __address__) into N buckets with the hashmod relabel action and keeps only its own bucket. Adding a shard changes the modulus, so most targets move and their series restart on another server.

relabel_configs:
  - source_labels: [__address__]
    modulus: 4
    target_label: __tmp_hash
    action: hashmod
  - source_labels: [__tmp_hash]
    regex: "2"
    action: keep

33. When is federation the right tool?

Federation lets a higher-level Prometheus scrape selected series from /federate on lower servers. It works for pulling a small set of pre-aggregated recording rule outputs to a global view. It is a poor fit for copying all raw data, because one federating server then carries every series and becomes the bottleneck.

34. How does Thanos extend Prometheus?

Thanos adds a sidecar next to each Prometheus that uploads completed blocks to object storage and serves recent data. Thanos Query fans out across sidecars and store gateways and deduplicates HA replicas. A compactor downsamples and compacts data in the bucket, and a ruler can evaluate global rules. It can also ingest remote write through its Receive component.

35. How do Cortex and Grafana Mimir differ from Thanos?

Cortex and Mimir are horizontally scalable, multi-tenant backends that receive data through remote write and store it in object storage. Thanos started from the sidecar model, keeping Prometheus as the source of recent data. Mimir began as a fork of Cortex by Grafana Labs. Choosing between them depends on tenancy needs, operational skills and whether you prefer push or sidecar ingestion.

OptionIngestionBest fit
FederationPull from /federateSmall global aggregates
ThanosSidecar upload or ReceiveKeep existing Prometheus servers, add global query and object storage
CortexRemote writeMulti-tenant central store
Grafana MimirRemote writeMulti-tenant central store, Grafana ecosystem

36. What is downsampling, and does it save storage?

Downsampling (in Thanos, done by the compactor) creates lower-resolution copies such as 5-minute and 1-hour aggregates so long-range queries read fewer samples. It speeds queries over months. It does not by itself reduce storage, because raw data is kept unless you set separate retention per resolution.

37. What do external labels do in a multi-server setup?

External labels such as cluster and replica are attached when data leaves the server: in federation, remote write, alerts and Thanos uploads. They identify the origin so global queries can group or deduplicate. Never let two servers share the same full set of external labels unless they are replicas meant to be deduplicated.

38. How do you size a single Prometheus server?

Start from active series and samples per second, not target count. Measure memory per series on your own workload from process_resident_memory_bytes divided by prometheus_tsdb_head_series, then add headroom for query load and WAL replay. Disk is roughly samples per second times bytes per sample times retention, plus the WAL peak. Measure rather than rely on rule-of-thumb figures.

Rules, security and operations (senior)

39. How do rule groups behave at scale?

Rules in one group run in order on the group's interval; different groups run concurrently. If one evaluation takes longer than the interval, iterations are missed, which shows in prometheus_rule_group_iterations_missed_total. Split slow groups and build heavy recording rules in layers so each level reads already-aggregated series.

40. What does keep_firing_for add to alerting rules?

keep_firing_for keeps an alert firing for a set time after its condition clears. It stops flapping alerts from resolving and re-firing during brief recoveries, which is a different control from for, which delays the first firing.

41. How do you add TLS and authentication to Prometheus itself?

Pass a web configuration file with --web.config.file. It supports tls_server_config for certificates and basic_auth_users with bcrypt-hashed passwords. Scrape-side TLS and auth to targets are set separately with tls_config and basic_auth in each scrape config.

tls_server_config:
  cert_file: /etc/prometheus/tls.crt
  key_file: /etc/prometheus/tls.key
basic_auth_users:
  admin: $2y$10$replace.with.bcrypt.hash

42. Which admin endpoints need extra care?

The TSDB admin APIs (snapshot, delete series, clean tombstones) are off unless you start with --web.enable-admin-api, and /-/reload and /-/quit need --web.enable-lifecycle. Keep both off unless you need them, and restrict network access to the server port 9090 either way.

Architecture scenarios

43. Design monitoring for 30 Kubernetes clusters with one global view.

Run an HA Prometheus pair per cluster with cluster and replica external labels. Either attach Thanos sidecars that upload to object storage and query through a central Thanos Query, or remote write to a central Mimir or Cortex. Keep alerting rules local so a central outage does not silence cluster alerts, and use global rules only for cross-cluster SLOs.

44. A single server has 8 million active series and keeps running out of memory. What is your plan?

First find the top metrics and labels on the TSDB status page and drop or fix the worst offenders with relabeling and sample_limit. If the real need is still that large, shard by team or by namespace into several servers, and put a global query layer on top. Adding RAM only buys time if churn keeps growing.

45. Edge sites have unreliable links. How do you collect their metrics?

Run Prometheus in agent mode at each site with remote write to a central store. The WAL buffers data during outages and the queue catches up when the link returns, within the WAL's retention. If late samples might be rejected centrally, configure an out-of-order window on the receiver.

46. Leadership wants 2 years of metrics at low cost. What do you propose?

Keep 15 to 30 days of raw data in Prometheus for fast queries, ship blocks or remote write to object storage through Thanos, Cortex or Mimir, and downsample older data. Use write_relabel_configs or recording rules so only the series needed for long-term trends are kept at full retention.

How to prepare

Read the storage and configuration pages on prometheus.io, then run Prometheus locally and watch the data directory as blocks are cut. Break it on purpose: add a high-cardinality label and watch prometheus_tsdb_head_series. If you want guided practice, our Prometheus and Grafana training runs in a classroom in Kharadi, Pune and live online across India. For background on how Prometheus and Grafana fit together, see Prometheus and Grafana together, and for the wider tool picture, top observability tools and SRE interview questions.

FAQ

How is this page different from the other Prometheus interview pages?

The 80+ guide covers fundamentals, the engineer page covers PromQL tasks, and the scenario page covers troubleshooting. This page covers internals and scale: TSDB, cardinality, remote write, native histograms, HA and long-term storage.

What is the default Prometheus retention?

15 days, when neither --storage.tsdb.retention.time nor --storage.tsdb.retention.size is set.

How long is a Prometheus TSDB block?

New blocks cover two hours. Compaction merges them into blocks of up to 10% of retention or 31 days, whichever is smaller.

Are native histograms stable?

Yes, from Prometheus v3.8.0. From v3.9 you enable scraping with scrape_native_histograms.

What is Prometheus agent mode?

A mode that scrapes and forwards data through remote write, with only a WAL and no local queries, rules or alerting.

Should I use Thanos, Cortex or Mimir?

Thanos fits if you want to keep existing Prometheus servers and add object storage and global queries. Cortex and Mimir fit a central, multi-tenant store fed by remote write.

Is there a Prometheus certification?

Yes. The Linux Foundation and CNCF offer the Prometheus Certified Associate (PCA). Check the Linux Foundation Training site for current details.

Official references

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.