From 40ac7102bcc8c36d8576dcc5e5e8187516b13e4c Mon Sep 17 00:00:00 2001 From: Changxin Miao Date: Thu, 13 Jun 2024 19:44:51 +0800 Subject: [PATCH] stats cmd should be robust enough to handle metrics with multiple labels (#4941) Signed-off-by: Changxin Miao --- cmd/stats.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/stats.go b/cmd/stats.go index 570245b14317..779ba219bb34 100644 --- a/cmd/stats.go +++ b/cmd/stats.go @@ -360,10 +360,11 @@ func readStats(mp string) map[string]float64 { for _, line := range lines { fields := strings.Fields(line) if len(fields) == 2 { - stats[fields[0]], err = strconv.ParseFloat(fields[1], 64) + v, err := strconv.ParseFloat(fields[1], 64) if err != nil { logger.Warnf("parse %s: %s", fields[1], err) } + stats[fields[0]] += v } } return stats