Data Retention and Storage
You'll learn how to configure Prometheus's local storage, set retention policies, and estimate disk space needs for your time-series metrics.
Why Storage Matters in Prometheus
Prometheus stores all scraped metrics locally on disk as time-series data. Unlike traditional databases, every metric point includes a timestamp and labels, which can consume significant disk space over time. Understanding how to manage this storage prevents your monitoring system from running out of space or keeping data longer than necessary.
Configuring Retention
Prometheus offers two retention controls via command-line flags:
--storage.tsdb.retention.time: How long to keep data (default: 15 days). Example:30dor6w--storage.tsdb.retention.size: Maximum storage size (e.g.,50GB). Prometheus deletes oldest data when this limit is reached
You can set both; whichever limit is hit first triggers cleanup.
Understanding Disk Requirements
Think of Prometheus storage like a rotating buffer: new data constantly arrives, old data gets deleted. Your disk needs depend on:
- Scrape frequency: Every 15 seconds vs. every minute drastically changes volume
- Number of targets: More services = more metrics
- Cardinality: How many unique label combinations exist (this multiplies storage exponentially)
A rough estimate: 1-2 bytes per sample on disk. If you scrape 10,000 metrics every 15s for 30 days, that's roughly 10,000 × 4 samples/min × 60 × 24 × 30 × 2 bytes ≈ 350GB.
Storage Path
By default, Prometheus stores data in ./data. Override with --storage.tsdb.path=/path/to/storage.
Key Takeaway: Configure Prometheus retention policies based on your observability needs and available disk space—balance historical visibility with infrastructure costs by setting appropriate time or size limits.