File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -443,6 +443,26 @@ func (m *Metrics) Total() LevelMetrics {
443443 return total
444444}
445445
446+ // RemoteTablesTotal returns the total number of remote tables and their total
447+ // size. Remote tables are computed as the difference between total tables
448+ // (live + obsolete + zombie) and local tables.
449+ func (m * Metrics ) RemoteTablesTotal () (count uint64 , size uint64 ) {
450+ var liveTables , liveTableBytes int64
451+ for level := 0 ; level < numLevels ; level ++ {
452+ liveTables += m .Levels [level ].NumFiles
453+ liveTableBytes += m .Levels [level ].Size
454+ }
455+ totalCount := liveTables + m .Table .ObsoleteCount + m .Table .ZombieCount
456+ localCount := m .Table .Local .LiveCount + m .Table .Local .ObsoleteCount + m .Table .Local .ZombieCount
457+ remoteCount := uint64 (totalCount ) - localCount
458+
459+ totalSize := uint64 (liveTableBytes ) + m .Table .ObsoleteSize + m .Table .ZombieSize
460+ localSize := m .Table .Local .LiveSize + m .Table .Local .ObsoleteSize + m .Table .Local .ZombieSize
461+ remoteSize := totalSize - localSize
462+
463+ return remoteCount , remoteSize
464+ }
465+
446466// String pretty-prints the metrics as below:
447467//
448468// | | | | ingested | moved | written | | amp
Original file line number Diff line number Diff line change @@ -395,6 +395,12 @@ func TestMetrics(t *testing.T) {
395395 panic (fmt .Sprintf ("invalid level %d" , l ))
396396 }
397397 buf .WriteString (fmt .Sprintf ("%d\n " , m .Levels [l ].NumVirtualFiles ))
398+ } else if line == "remote-count" {
399+ count , _ := m .RemoteTablesTotal ()
400+ buf .WriteString (fmt .Sprintf ("%d\n " , count ))
401+ } else if line == "remote-size" {
402+ _ , size := m .RemoteTablesTotal ()
403+ buf .WriteString (fmt .Sprintf ("%s\n " , humanize .Bytes .Uint64 (size )))
398404 } else {
399405 panic (fmt .Sprintf ("invalid field: %s" , line ))
400406 }
@@ -427,6 +433,7 @@ func TestMetrics(t *testing.T) {
427433 return fmt .Sprintf ("unknown command: %s" , td .Cmd )
428434 }
429435 })
436+
430437}
431438
432439func TestMetricsWAmpDisableWAL (t * testing.T ) {
Original file line number Diff line number Diff line change @@ -870,6 +870,13 @@ set b 2
870870ingest ext1.sst
871871----
872872
873+ metrics-value
874+ remote-count
875+ remote-size
876+ ----
877+ 2
878+ 1.5KB
879+
873880lsm
874881----
875882L0.0:
You can’t perform that action at this time.
0 commit comments