How is the Prometheus TSDB organized on disk?

AdvancedConceptPrometheus Architecture
Answer
  • Head block in memory holds the most recent samples (about 2 to 3 hours), backed by the WAL (wal/ directory, 128 MB segments) for crash recovery, plus memory-mapped head chunks (chunks_head/).
  • Every 2 hours the head is compacted into an immutable block directory (ULID name) containing chunks/, index, meta.json and tombstones.
  • Background compaction merges small blocks into larger ones (up to 10% of retention or 31 days).

Samples are compressed with Gorilla-style delta-of-delta timestamps and XOR values, around 1.3 bytes per sample. Deletes only write tombstones until compaction.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Prometheus Architecture