Skip to content

feat(metrics): export per-level SST file counts to Prometheus#189

Open
philippem wants to merge 1 commit intoBlockstream:new-indexfrom
philippem:add-rocksdb-levels-exporter
Open

feat(metrics): export per-level SST file counts to Prometheus#189
philippem wants to merge 1 commit intoBlockstream:new-indexfrom
philippem:add-rocksdb-levels-exporter

Conversation

@philippem
Copy link
Collaborator

Adds rocksdb_num_files_at_level{db, level} gauge, polled every 5s via the existing stats exporter loop. Covers levels 0-6 (RocksDB default). Useful for monitoring L0 file accumulation during initial sync.

Adds rocksdb_num_files_at_level{db, level} gauge, polled every 5s
via the existing stats exporter loop. Covers levels 0-6 (RocksDB default).
Useful for monitoring L0 file accumulation during initial sync.
@philippem philippem requested a review from RCasatta March 4, 2026 14:48
@EddieHouston
Copy link

lgtm

Copy link
Collaborator

@shesek shesek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, two minor nits but I'd also be fine with it as-is.

let prop = format!("rocksdb.num-files-at-level{}", level);
let level_str = level.to_string();
if let Ok(Some(value)) = db_arc_levels.property_value(&prop) {
if let Ok(v) = value.parse::<f64>() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches the existing update_gauge() behavior, but its kind of strange that invalid values are silently discarded. Maybe log a warnings if parse::<f64> fails?

for level in 0..7u32 {
let prop = format!("rocksdb.num-files-at-level{}", level);
let level_str = level.to_string();
if let Ok(Some(value)) = db_arc_levels.property_value(&prop) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe handle the per-level gauges through update_gauge() too? It can take an additional_labels: &[&str] argument and concat() it with the default db name label.

This would reduce some duplication and make the extra db_arc_levels/label_levels clones unnecessary.

update_gauge(&db_metrics.block_cache_capacity, "rocksdb.block-cache-capacity");
update_gauge(&db_metrics.block_cache_usage, "rocksdb.block-cache-usage");
update_gauge(&db_metrics.block_cache_pinned_usage, "rocksdb.block-cache-pinned-usage");
for level in 0..7u32 {
Copy link
Collaborator

@shesek shesek Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use a ROCKSDB_NUM_LEVELS const (with ..=)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants