Prometheus’ TSDB
Prometheus’s TSDB is at the core of all that Prometheus does. It’s been in its third iteration since 2017 and continues to be regularly updated with new optimizations and features. However, its core functionality and format have largely remained the same.
Understanding how the TSDB works will enable you to understand Prometheus’s internals in a new way that can inform how you maintain and use Prometheus. The core parts of the TSDB that we’ll look at are its head block, write-ahead log (WAL), and data format (blocks, chunks, and indices), as well as how compaction works.
Head block
The head block in Prometheus is the first stop for samples being scraped and stored in Prometheus’ TSDB. It is an in-memory block (more on the specifics of a block later) containing various chunks for each of the different time series you’re collecting. This block can contain millions of chunks, depending on the number of scrape targets...