Prometheus Metrics
ZeroFS can expose metrics in Prometheus format over an HTTP endpoint.
Configuration
Add a [prometheus] section to your configuration file:
[prometheus]
addresses = ["127.0.0.1:9091"]
This starts an HTTP server on the specified address. Metrics are available at /metrics:
curl http://127.0.0.1:9091/metrics
Multiple bind addresses are supported, following the same pattern as other ZeroFS servers:
[prometheus]
addresses = ["127.0.0.1:9091", "[::1]:9091"] # Dual-stack localhost
Each entry binds one listener, so the addresses must not overlap. 0.0.0.0:9091 already accepts loopback connections; adding 127.0.0.1:9091 alongside it conflicts on the same port, and the losing bind is logged and dropped.
addresses defaults to 127.0.0.1:9091. An empty [prometheus] section is valid and starts the endpoint on that address. When the [prometheus] section is absent, no metrics endpoint is started.
Available Metrics
Filesystem Operations
Counters that track cumulative operations since server start:
| Metric | Type | Description |
|---|---|---|
zerofs_files_created_total | counter | Files created |
zerofs_files_deleted_total | counter | Files deleted |
zerofs_files_renamed_total | counter | Files renamed |
zerofs_directories_created_total | counter | Directories created |
zerofs_directories_deleted_total | counter | Directories deleted |
zerofs_directories_renamed_total | counter | Directories renamed |
zerofs_links_created_total | counter | Links created |
zerofs_links_deleted_total | counter | Links deleted |
zerofs_links_renamed_total | counter | Links renamed |
I/O
| Metric | Type | Description |
|---|---|---|
zerofs_read_operations_total | counter | Total read operations |
zerofs_write_operations_total | counter | Total write operations |
zerofs_bytes_read_total | counter | Total bytes read |
zerofs_bytes_written_total | counter | Total bytes written |
zerofs_total_operations | counter | Total operations across all types |
Tombstone Cleanup
| Metric | Type | Description |
|---|---|---|
zerofs_tombstones_created_total | counter | Tombstones created for deleted data |
zerofs_tombstones_processed_total | counter | Tombstones processed by cleanup |
zerofs_tombstone_cleanup_extents_deleted_total | counter | Extents removed by tombstone cleanup |
zerofs_tombstone_cleanup_runs_total | counter | Tombstone-cleanup cycles started |
The metrics above cover the tombstone-cleanup worker that removes a deleted file's extents. Segment reclamation and repacking, which recover dead space inside the immutable segment objects that hold file data, are reported separately below.
Segment Footprint
These gauges describe encoded frame bytes tracked by segment counters, including committed frames still in the open or sealing buffers. They are seeded from a counter scan at open and updated as writes, repoints, and deletions commit, so dead space remains current between reclamation cycles.
| Metric | Type | Description |
|---|---|---|
zerofs_segment_count | gauge | Segments tracked by live-byte counters, including an unflushed open segment once it has committed frames |
zerofs_segment_appended_bytes | gauge | Encoded frame bytes appended across tracked segments; excludes segment directory/footer framing, so a sealed object's contribution is below its physical object size |
zerofs_segment_live_bytes | gauge | Referenced (live) bytes across all segments |
zerofs_segment_reclaimable_bytes | gauge | Dead bytes recoverable by deletion or repacking (appended minus live) |
zerofs_segment_dead_ratio | gauge | Reclaimable over appended, from 0 to 1 |
Segment Reclamation and Repacking
Counters accumulate across reclamation cycles since server start. Safety-window gauges describe pending deletion, while executor gauges measure work in flight at scrape time. Each cycle scans the segment counters, deletes fully dead segments, and drives concurrent repack jobs; the daily orphan sweep handles counter-less objects.
| Metric | Type | Description |
|---|---|---|
zerofs_segment_reclaim_cycles_total | counter | Reclamation cycles completed |
zerofs_segment_reclaim_segments_deleted_total | counter | Fully-dead segment objects deleted |
zerofs_segment_reclaim_deleted_bytes_total | counter | Tracked frame bytes attributed to deleted dead segments; physical objects also contain directory/footer framing |
zerofs_segment_reclaim_repack_sources_total | counter | Source segments consumed by repacking |
zerofs_segment_reclaim_frames_relocated_total | counter | Extent frames rewritten during repacking |
zerofs_segment_reclaim_repack_jobs_total | counter | Independent repack jobs run |
zerofs_segment_reclaim_orphans_reclaimed_total | counter | Counter-less orphan objects reclaimed by the slow sweep |
zerofs_segment_reclaim_awaiting_delete | gauge | Fully dead segments pending deletion, including those waiting out their safety horizon |
zerofs_segment_reclaim_awaiting_delete_bytes | gauge | Encoded frame bytes in segments pending deletion |
zerofs_segment_reclaim_active_repacks | gauge | Independent repack jobs currently gathering, packing, or repointing |
zerofs_segment_reclaim_active_fetches | gauge | Logical segment fetches in flight; a directory fetch performs a footer GET plus a directory GET |
zerofs_segment_reclaim_active_puts | gauge | Packed-output PUTs currently in flight |
zerofs_segment_reclaim_active_deletes | gauge | Object DELETEs in flight, including dead segments, orphan-sweep objects, and unused packed outputs |
zerofs_segment_reclaim_repack_memory_reserved_bytes | gauge | Actual gather-memory charge reserved by active repack jobs |
zerofs_segment_reclaim_repack_memory_budget_bytes | gauge | Nominal aggregate budget in bytes: max_concurrent_repacks × 256 × 1024 × 1024; a first source may exceed its soft budget but never the 1 GiB per-job segment limit |
Segment reclamation and repacking run only on the read-write leader. Read replicas and checkpoint mounts run no reclamation, so these series stay flat there.
Filesystem State
| Metric | Type | Description |
|---|---|---|
zerofs_used_bytes | gauge | Total bytes stored in the filesystem |
zerofs_used_inodes | gauge | Total active inodes (files, directories, symlinks, and special files) |
zerofs_dedup_retained_results | gauge | Completed mutation results retained for retry replay |
zerofs_dedup_inflight_ids | gauge | Mutation IDs currently being applied |
zerofs_dedup_replay_pinned_results | gauge | Retained results currently pinned while a retry response is reconstructed |
Memory (jemalloc)
Gauges that report the state of the jemalloc allocator:
| Metric | Type | Description |
|---|---|---|
zerofs_jemalloc_allocated_bytes | gauge | Bytes actively allocated by the application |
zerofs_jemalloc_resident_bytes | gauge | Bytes in physically resident pages mapped by the allocator |
zerofs_jemalloc_mapped_bytes | gauge | Bytes in active pages mapped by the allocator |
zerofs_jemalloc_retained_bytes | gauge | Bytes in virtual memory mappings retained for future reuse |
zerofs_jemalloc_metadata_bytes | gauge | Bytes dedicated to allocator metadata |
zerofs_jemalloc_resident_bytes tracks the allocator's physical memory footprint. zerofs_jemalloc_retained_bytes counts virtual address space kept for reuse and does not consume physical memory, so memory alerts should key on resident, not retained or mapped.
Metadata LSM
ZeroFS exposes internal metrics from its metadata LSM tree, which holds inode and directory metadata plus per-extent pointers; file content lives in segment objects outside the LSM. These metrics are prefixed with lsm_ and include compaction and storage statistics. The exact metrics depend on the engine version and are discovered at runtime.
Common metadata metrics include:
| Metric | Type | Description |
|---|---|---|
lsm_compactor_bytes_compacted | counter | Total bytes processed by compaction |
lsm_compactor_running_compactions | gauge | Number of active compaction tasks |
lsm_compactor_total_bytes_being_compacted | gauge | Bytes currently being compacted |
Compaction metrics cover metadata compaction only. Segment objects holding file data are not part of the LSM and are never rewritten by it.
The lsm_-prefixed metrics are only available in read-write mode; read-only instances do not expose them.
Prometheus Scrape Configuration
Add ZeroFS as a target in your prometheus.yml:
scrape_configs:
- job_name: 'zerofs'
scrape_interval: 15s
static_configs:
- targets: ['localhost:9091']
A background task collects all metric values every 5 seconds, and the endpoint serves the last collected values. A scrape_interval below 5 seconds does not increase resolution.