diff --git a/index/scorch/scorch.go b/index/scorch/scorch.go index 2b5408514..fdfde0989 100644 --- a/index/scorch/scorch.go +++ b/index/scorch/scorch.go @@ -658,6 +658,17 @@ func (s *Scorch) StatsMap() map[string]interface{} { m["num_persister_nap_merger_break"] = m["TotPersisterMergerNapBreak"] m["total_compaction_written_bytes"] = m["TotFileMergeWrittenBytes"] + // the bool stat `index_bgthreads_active` indicates whether the background routines + // (which are responsible for the index to attain a steady state) are still + // doing some work. + if rootEpoch, ok := m["CurRootEpoch"].(uint64); ok { + if lastMergedEpoch, ok := m["LastMergedEpoch"].(uint64); ok { + if lastPersistedEpoch, ok := m["LastPersistedEpoch"].(uint64); ok { + m["index_bgthreads_active"] = !(lastMergedEpoch == rootEpoch && lastPersistedEpoch == rootEpoch) + } + } + } + // calculate the aggregate of all the segment's field stats aggFieldStats := newFieldStats() for _, segmentSnapshot := range indexSnapshot.Segments() {