diff --git a/crates/typed-store/src/metrics.rs b/crates/typed-store/src/metrics.rs index 904ad5a31cf67d..320765e6ad441e 100644 --- a/crates/typed-store/src/metrics.rs +++ b/crates/typed-store/src/metrics.rs @@ -88,6 +88,7 @@ pub struct ColumnFamilyMetrics { pub rocksdb_estimate_table_readers_mem: IntGaugeVec, pub rocksdb_mem_table_flush_pending: IntGaugeVec, pub rocksdb_compaction_pending: IntGaugeVec, + pub rocksdb_estimate_pending_compaction_bytes: IntGaugeVec, pub rocksdb_num_running_compactions: IntGaugeVec, pub rocksdb_num_running_flushes: IntGaugeVec, pub rocksdb_estimate_oldest_key_time: IntGaugeVec, @@ -198,6 +199,14 @@ impl ColumnFamilyMetrics { registry, ) .unwrap(), + rocksdb_estimate_pending_compaction_bytes: register_int_gauge_vec_with_registry!( + "rocksdb_compaction_pending", + "Estimated total number of bytes compaction needs to rewrite to get all levels down + to under target size. Not valid for other compactions than level-based.", + &["cf_name"], + registry, + ) + .unwrap(), rocksdb_num_running_compactions: register_int_gauge_vec_with_registry!( "rocksdb_num_running_compactions", "The number of compactions that are currently running for the column family.", diff --git a/crates/typed-store/src/rocks/mod.rs b/crates/typed-store/src/rocks/mod.rs index ca6505b9a448ef..a1faba87ae531c 100644 --- a/crates/typed-store/src/rocks/mod.rs +++ b/crates/typed-store/src/rocks/mod.rs @@ -704,7 +704,7 @@ impl MetricConf { } } } -const CF_METRICS_REPORT_PERIOD_MILLIS: u64 = 1000; +const CF_METRICS_REPORT_PERIOD_SECS: u64 = 30; const METRICS_ERROR: i64 = -1; /// An interface to a rocksDB database, keyed by a columnfamily @@ -740,7 +740,7 @@ impl DBMap { if !is_deprecated { tokio::task::spawn(async move { let mut interval = - tokio::time::interval(Duration::from_millis(CF_METRICS_REPORT_PERIOD_MILLIS)); + tokio::time::interval(Duration::from_secs(CF_METRICS_REPORT_PERIOD_SECS)); loop { tokio::select! { _ = interval.tick() => { @@ -1079,6 +1079,14 @@ impl DBMap { Self::get_int_property(rocksdb, &cf, properties::COMPACTION_PENDING) .unwrap_or(METRICS_ERROR), ); + db_metrics + .cf_metrics + .rocksdb_estimate_pending_compaction_bytes + .with_label_values(&[cf_name]) + .set( + Self::get_int_property(rocksdb, &cf, properties::ESTIMATE_PENDING_COMPACTION_BYTES) + .unwrap_or(METRICS_ERROR), + ); db_metrics .cf_metrics .rocksdb_num_running_compactions