Use it when sizing Prometheus or when disk/memory is exhausted.
Prometheus Storage and Retention
Prometheus stores data in a local TSDB (head block in memory + WAL, then 2-hour blocks compacted) with retention by time or size; long-term storage uses remote_write to Thanos, Mimir or similar.
1. TSDB stats: curl -s localhost:9090/api/v1/status/tsdb.
2. Disk usage of data dir.
3. Retention flags.
4. remote_write queue health (prometheus_remote_storage_*).
5. Plan capacity.
samples → head/WAL → blocks → compaction → retention/remote
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 How to verify Verify boundary
Confirm the oldest data matches retention. Check remote write keeps up during peaks.
Step 2 Checks Verify boundary
curl -s localhost:9090/api/v1/status/tsdb | jq '.data.headStats'
curl -s localhost:9090/api/v1/status/runtimeinfo
promtool tsdb analyze /prometheus
tsdb analyze shows the highest-cardinality metrics and labels; headStats.numSeries growing fast means a cardinality problem.
Step 3 Common failures Narrow the fault
High-cardinality metrics exhaust memory before disk. Disk full corrupts or stops ingestion. Remote write falling behind grows memory until Prometheus is OOM-killed.
Memory is driven by active series. Set --storage.tsdb.retention.time or .size. Local storage is single-node — use remote_write for HA and long retention.
curl -s localhost:9090/api/v1/status/tsdb— first check for this topiccurl -s localhost:9090/-/ready— Prometheus readycurl -s 'localhost:9090/api/v1/query?query=up'— scrape targets up/downpromtool check config prometheus.yml— config valid
ReferenceWhat it is1 section · depth on demand
How it works
New samples go into an in-memory head block with a write-ahead log, then are compacted into two-hour blocks and larger blocks on disk. Retention deletes whole blocks.
ReferenceImportant terms & boundaries3 sections · depth on demand
Retention settings
--storage.tsdb.retention.time=15d
--storage.tsdb.retention.size=200GB
Rough sizing: samples/s × bytes per sample (~1–2 bytes) × retention seconds. For long-term storage and HA use remote write to Thanos, Mimir, Cortex or VictoriaMetrics. Prometheus local storage is not replicated; run two identical Prometheus servers for HA.
In depth
How data moves through the TSDB
1. New samples go into the in-memory head block and are written to the WAL for crash safety.
2. Every two hours the head is cut into a persistent block on disk.
3. Compaction merges blocks into larger ones (up to 10 % of the retention period, max 31 days).
4. Blocks older than the retention time (or beyond the size limit) are deleted whole.
Sizing
Disk ≈ retention seconds × samples per second × bytes per sample, with about 1–2 bytes per sample after compression. Example: 500,000 active series scraped every 15 s = 33,000 samples/s; for 15 days: 33,000 × 1,296,000 × 1.5 ≈ 64 GB, plus WAL and compaction headroom (plan for roughly double).
Memory is driven mainly by active series in the head block, not by retention: a cardinality explosion runs out of memory long before it runs out of disk.
prometheus_tsdb_head_series # active series
rate(prometheus_tsdb_head_samples_appended_total[5m]) # samples/s ingested
prometheus_tsdb_storage_blocks_bytes # disk used by blocks
Retention flags
--storage.tsdb.retention.time=15d and/or --storage.tsdb.retention.size=200GB; whichever is hit first deletes the oldest blocks. Leave room for the WAL and one compaction, so size retention below the disk size.
Long-term storage
Local Prometheus storage is single-node and not replicated. For long retention, global queries or high availability, use remote write to a scalable backend (Thanos, Mimir, Cortex, VictoriaMetrics), and watch the queue:
prometheus_remote_storage_highest_timestamp_in_seconds
- ignoring(remote_name, url) group_right prometheus_remote_storage_queue_highest_sent_timestamp_seconds
A growing value means remote write is falling behind; when it exceeds the WAL retention, samples are lost.
Common mistakes
- Retention set without disk sizing.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.