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:

MetricTypeDescription
zerofs_files_created_totalcounterFiles created
zerofs_files_deleted_totalcounterFiles deleted
zerofs_files_renamed_totalcounterFiles renamed
zerofs_directories_created_totalcounterDirectories created
zerofs_directories_deleted_totalcounterDirectories deleted
zerofs_directories_renamed_totalcounterDirectories renamed
zerofs_links_created_totalcounterLinks created
zerofs_links_deleted_totalcounterLinks deleted
zerofs_links_renamed_totalcounterLinks renamed

I/O

MetricTypeDescription
zerofs_read_operations_totalcounterTotal read operations
zerofs_write_operations_totalcounterTotal write operations
zerofs_bytes_read_totalcounterTotal bytes read
zerofs_bytes_written_totalcounterTotal bytes written
zerofs_total_operationscounterTotal operations across all types

Tombstone Cleanup

MetricTypeDescription
zerofs_tombstones_created_totalcounterTombstones created for deleted data
zerofs_tombstones_processed_totalcounterTombstones processed by cleanup
zerofs_tombstone_cleanup_extents_deleted_totalcounterExtents removed by tombstone cleanup
zerofs_tombstone_cleanup_runs_totalcounterTombstone-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.

MetricTypeDescription
zerofs_segment_countgaugeSegments tracked by live-byte counters, including an unflushed open segment once it has committed frames
zerofs_segment_appended_bytesgaugeEncoded 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_bytesgaugeReferenced (live) bytes across all segments
zerofs_segment_reclaimable_bytesgaugeDead bytes recoverable by deletion or repacking (appended minus live)
zerofs_segment_dead_ratiogaugeReclaimable 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.

MetricTypeDescription
zerofs_segment_reclaim_cycles_totalcounterReclamation cycles completed
zerofs_segment_reclaim_segments_deleted_totalcounterFully-dead segment objects deleted
zerofs_segment_reclaim_deleted_bytes_totalcounterTracked frame bytes attributed to deleted dead segments; physical objects also contain directory/footer framing
zerofs_segment_reclaim_repack_sources_totalcounterSource segments consumed by repacking
zerofs_segment_reclaim_frames_relocated_totalcounterExtent frames rewritten during repacking
zerofs_segment_reclaim_repack_jobs_totalcounterIndependent repack jobs run
zerofs_segment_reclaim_orphans_reclaimed_totalcounterCounter-less orphan objects reclaimed by the slow sweep
zerofs_segment_reclaim_awaiting_deletegaugeFully dead segments pending deletion, including those waiting out their safety horizon
zerofs_segment_reclaim_awaiting_delete_bytesgaugeEncoded frame bytes in segments pending deletion
zerofs_segment_reclaim_active_repacksgaugeIndependent repack jobs currently gathering, packing, or repointing
zerofs_segment_reclaim_active_fetchesgaugeLogical segment fetches in flight; a directory fetch performs a footer GET plus a directory GET
zerofs_segment_reclaim_active_putsgaugePacked-output PUTs currently in flight
zerofs_segment_reclaim_active_deletesgaugeObject DELETEs in flight, including dead segments, orphan-sweep objects, and unused packed outputs
zerofs_segment_reclaim_repack_memory_reserved_bytesgaugeActual gather-memory charge reserved by active repack jobs
zerofs_segment_reclaim_repack_memory_budget_bytesgaugeNominal 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

MetricTypeDescription
zerofs_used_bytesgaugeTotal bytes stored in the filesystem
zerofs_used_inodesgaugeTotal active inodes (files, directories, symlinks, and special files)
zerofs_dedup_retained_resultsgaugeCompleted mutation results retained for retry replay
zerofs_dedup_inflight_idsgaugeMutation IDs currently being applied
zerofs_dedup_replay_pinned_resultsgaugeRetained results currently pinned while a retry response is reconstructed

Memory (jemalloc)

Gauges that report the state of the jemalloc allocator:

MetricTypeDescription
zerofs_jemalloc_allocated_bytesgaugeBytes actively allocated by the application
zerofs_jemalloc_resident_bytesgaugeBytes in physically resident pages mapped by the allocator
zerofs_jemalloc_mapped_bytesgaugeBytes in active pages mapped by the allocator
zerofs_jemalloc_retained_bytesgaugeBytes in virtual memory mappings retained for future reuse
zerofs_jemalloc_metadata_bytesgaugeBytes 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:

MetricTypeDescription
lsm_compactor_bytes_compactedcounterTotal bytes processed by compaction
lsm_compactor_running_compactionsgaugeNumber of active compaction tasks
lsm_compactor_total_bytes_being_compactedgaugeBytes 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.

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.

Was this page helpful?