From 542906b15298b2e33b2866d47b7b866c51f37e34 Mon Sep 17 00:00:00 2001 From: Edward Welch Date: Tue, 4 Aug 2020 06:28:23 -0400 Subject: [PATCH] Make a clone of the LabelSet before handling, the handler contains a full pipeline and can modify the labels uniquely per each line which will lead to some concurrent map access panics if you don't pass a copy of the labels to each Handle invocation. --- pkg/promtail/targets/lokipush/pushtarget.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/promtail/targets/lokipush/pushtarget.go b/pkg/promtail/targets/lokipush/pushtarget.go index 3dec7a8b20256..ed5cac29ae434 100644 --- a/pkg/promtail/targets/lokipush/pushtarget.go +++ b/pkg/promtail/targets/lokipush/pushtarget.go @@ -146,9 +146,9 @@ func (t *PushTarget) handle(w http.ResponseWriter, r *http.Request) { for _, entry := range stream.Entries { var err error if t.config.KeepTimestamp { - err = t.handler.Handle(filtered, entry.Timestamp, entry.Line) + err = t.handler.Handle(filtered.Clone(), entry.Timestamp, entry.Line) } else { - err = t.handler.Handle(filtered, time.Now(), entry.Line) + err = t.handler.Handle(filtered.Clone(), time.Now(), entry.Line) } if err != nil {