How does Prometheus storage (TSDB) work, and what is the retention model? [Intermediate]
Answer
Prometheus stores samples in its local time-series database, using in-memory head blocks for recent data and immutable blocks on disk for older data. Retention is controlled by time and/or size, after which old blocks are deleted.
Technical explanation
The TSDB is optimized for recent local queries and rule evaluation.
Retention flags such as storage.tsdb.retention.time and storage.tsdb.retention.size define how much data stays locally.
For long-term historical data, remote write or object-storage-based systems such as Thanos, Cortex, or Mimir are commonly used.
Hands-on example
Hands-on: set Prometheus args to --storage.tsdb.retention.time=15d and --storage.tsdb.retention.size=100GB. Monitor prometheus_tsdb_head_series, prometheus_tsdb_storage_blocks_bytes, and disk usage. If head series grows sharply, investigate cardinality before increasing disk.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Observability interview questions
- How does Prometheus handle high cardinality, and why is it a problem? [Intermediate]
- What is the difference between Thanos and Cortex/Mimir at a high level? [Intermediate]
- How does Prometheus integrate with Kubernetes service discovery? [Intermediate]
- What is the Prometheus Operator, and what are ServiceMonitor and PodMonitor? [Intermediate]
- What is an alerting rule, and how does it differ from a recording rule? [Basic]
- What is a recording rule, and when would you use one? [Basic]
- How do you compute a 95th percentile latency from a histogram in PromQL (histogram_quantile)? [Basic]
- What is the difference between rate() and irate()? [Basic]