File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -255,7 +255,9 @@ impl DB {
255255
256256 pub fn start_stats_exporter ( & self , db_metrics : Arc < RocksDbMetrics > , db_name : & str ) {
257257 let db_arc = Arc :: clone ( & self . db ) ;
258+ let db_arc_levels = Arc :: clone ( & self . db ) ;
258259 let label = db_name. to_string ( ) ;
260+ let label_levels = label. clone ( ) ;
259261
260262 let update_gauge = move |gauge : & GaugeVec , property : & str | {
261263 if let Ok ( Some ( value) ) = db_arc. property_value ( property) {
@@ -299,6 +301,17 @@ impl DB {
299301 update_gauge ( & db_metrics. block_cache_capacity , "rocksdb.block-cache-capacity" ) ;
300302 update_gauge ( & db_metrics. block_cache_usage , "rocksdb.block-cache-usage" ) ;
301303 update_gauge ( & db_metrics. block_cache_pinned_usage , "rocksdb.block-cache-pinned-usage" ) ;
304+ for level in 0 ..7u32 {
305+ let prop = format ! ( "rocksdb.num-files-at-level{}" , level) ;
306+ let level_str = level. to_string ( ) ;
307+ if let Ok ( Some ( value) ) = db_arc_levels. property_value ( & prop) {
308+ if let Ok ( v) = value. parse :: < f64 > ( ) {
309+ db_metrics. num_files_at_level
310+ . with_label_values ( & [ & label_levels, & level_str] )
311+ . set ( v) ;
312+ }
313+ }
314+ }
302315 thread:: sleep ( Duration :: from_secs ( 5 ) ) ;
303316 } ) ;
304317 }
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ pub struct RocksDbMetrics {
4949
5050 // Level metrics
5151 pub base_level : GaugeVec ,
52+ pub num_files_at_level : GaugeVec ,
5253
5354 // Write metrics
5455 pub actual_delayed_write_rate : GaugeVec ,
@@ -204,6 +205,10 @@ impl RocksDbMetrics {
204205 format ! ( "rocksdb_base_level" ) ,
205206 "Base level for compaction."
206207 ) , labels) ,
208+ num_files_at_level : metrics. gauge_vec ( MetricOpts :: new (
209+ "rocksdb_num_files_at_level" ,
210+ "Number of SST files at each compaction level."
211+ ) , & [ "db" , "level" ] ) ,
207212
208213 // Write metrics
209214 actual_delayed_write_rate : metrics. gauge_vec ( MetricOpts :: new (
You can’t perform that action at this time.
0 commit comments