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.jsonandtombstones. - 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.
More on Prometheus Architecture
Describe the Prometheus architecture.BeginnerWhat does a basic prometheus.yml look like?BeginnerWhat is the `up` metric?BeginnerWhat are `job` and `instance` labels and where do they come from?BeginnerWhat is the WAL and why does Prometheus restart slowly sometimes?AdvancedHow do you configure Prometheus retention?Beginner