Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
tsdb-reader
Zero-copy, read-only parser for Prometheus TSDB blocks.
The crate implements exactly what a full sequential export needs — index TOC and symbols, series traversal, chunk segment access with CRC32C validation, all chunk encodings and tombstones filtering — and nothing more. It is an independent library so other tools can read blocks without reimplementing the on-disk formats.
What it supports
| Area | Coverage |
|---|---|
| Index format | v1, v2, v3 (Prometheus 2.x–3.x) |
| Chunk encodings | XOR, XOR2, histogram, float histogram, and their ST variants |
| Tombstones | v1, closed intervals, merged on load |
| Layout | Prometheus data directory or a single block directory |
What it does not support
chunks_head/and the WAL — only persisted blocks.- The postings / label-index sections, so there is no matcher API; series are visited sequentially in lexicographic label order.
- Writing blocks.
no_stdorwasm32-unknown-unknown: the crate maps files withmemmap2and relies onstd::fs.
Cargo features
All three are enabled by default. default-features = false leaves only
serde and thiserror, which the type definitions need.
| Feature | Default | Pulls in | Turn it off to |
|---|---|---|---|
mmap |
on | memmap2 |
drop the memory-mapping dependency and read segments into owned buffers |
crc |
on | crc32c |
skip checksum verification entirely and drop the CRC dependency |
meta |
on | serde_json |
drop JSON parsing and supply BlockMeta from your own store |
The features are independent: any combination compiles and is tested in CI.
What changes without them:
mmapoff —IndexReader::openandChunkReader::openread files into memory instead of mapping them.IndexReader::from_bytesandChunkReader::from_segmentsaccept buffers either way, so object-store and in-memory pipelines are unaffected.IndexReader::from_mmaponly exists with the feature on.crcoff —ReaderOptions::verify_crcand theverify_crcarguments become no-ops;Error::Checksumis never produced. Corrupt data then surfaces as a parse error, or not at all.metaoff —read_meta,discover_blocksandBlockReader::openare not compiled. UseBlockReader::open_with_meta(path, meta, opts)orBlockReader::open_info(info, opts)instead.
Install
[]
= "0.1"
Example
#
Decoding samples is a two-step process: walk the series, then decode each chunk into a sink of your own.
#
Threading model
ChunkReader is Send + Sync: chunk segments can be decoded from several
threads at once (BlockReader::chunk_reader() or into_parts()).
IndexReader and therefore BlockReader are Send but not Sync — the
symbol cache is a RefCell, so index traversal must stay on one thread.
Verification
Every byte-level detail is cross-checked against fixtures generated by the
upstream Prometheus implementation. The small golden block and chunk fixtures
ship in tests/data, so cargo test works from a checkout or package tarball
without Go or other repositories.
License
MIT — see LICENSE.
The chunk decoders in src/chunkenc/ are a Rust port of Prometheus' TSDB
encoders and stay under the Apache License 2.0 (see LICENSE-APACHE and
NOTICE for the exact file list and attribution).