From 8afdd9bc7b9104f0d8faba9412c19c13c640f241 Mon Sep 17 00:00:00 2001 From: alexgreenbank Date: Tue, 14 Jan 2025 15:32:46 +0000 Subject: [PATCH] fix parsing string replacing code Signed-off-by: alexgreenbank --- pkg/distributor/influxpush/parser.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/distributor/influxpush/parser.go b/pkg/distributor/influxpush/parser.go index b3882fd744e..a567ec81100 100644 --- a/pkg/distributor/influxpush/parser.go +++ b/pkg/distributor/influxpush/parser.go @@ -104,10 +104,14 @@ func influxPointToTimeseries(pt models.Point, returnTs []mimirpb.PreallocTimeser continue } - name := replaceInvalidChars(pt.Name()) + // Make a copy of pt.Name() otherwise the replaceInvalidChars() modifies the data + // by possibly prepending to the slice which upsets subsequent calls to pt.Name() + name := append([]byte{}, pt.Name()...) + name = replaceInvalidChars(name) if field != "value" { // If the field name is not "value" then we append it to the name, fixing chars as we go - name = append([]byte{'_'}, name...) + name = append(name, byte('_')) + name = append(name, replaceInvalidChars([]byte(field))...) } tags := pt.Tags()