diff --git a/pkg/tikvapi/tikvapi.go b/pkg/tikvapi/tikvapi.go index 77868c75d86..255b55cffe8 100644 --- a/pkg/tikvapi/tikvapi.go +++ b/pkg/tikvapi/tikvapi.go @@ -56,8 +56,12 @@ func (c *tikvClient) GetLeaderCount() (int, error) { } }() - for mf := range mfChan { - fm := prom2json.NewFamily(mf) + fms := []*prom2json.Family{} + for mfc := range mfChan { + fm := prom2json.NewFamily(mfc) + fms = append(fms, fm) + } + for _, fm := range fms { if fm.Name == metricNameRegionCount { for _, m := range fm.Metrics { if m, ok := m.(prom2json.Metric); ok && m.Labels["type"] == labelNameLeaderCount {