From c97b7f1b27e55deab7f4f282048aeb79c456a749 Mon Sep 17 00:00:00 2001 From: George Robinson Date: Mon, 29 Jan 2024 18:04:52 +0000 Subject: [PATCH] Fix nil error in warn logs about incompatible matchers (#3683) This commit fixes a small bug in the warning logs for incompatible matchers where the error from the UTF-8 parser was logged as nil. Signed-off-by: George Robinson --- matchers/compat/parse.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/matchers/compat/parse.go b/matchers/compat/parse.go index 4a9bfe89..e6b2758b 100644 --- a/matchers/compat/parse.go +++ b/matchers/compat/parse.go @@ -170,7 +170,7 @@ func FallbackMatcherParser(l log.Logger, m *Metrics) ParseMatcher { // parser. This means the input is not forwards compatible. m.IncompatibleTotal.With(lbs).Inc() suggestion := cMatcher.String() - level.Warn(l).Log("msg", "Alertmanager is moving to a new parser for labels and matchers, and this input is incompatible. Alertmanager has instead parsed the input using the old matchers parser as a fallback. To make this input compatible with the new parser please make sure all regular expressions and values are double-quoted. If you are still seeing this message please open an issue.", "input", input, "origin", origin, "err", err, "suggestion", suggestion) + level.Warn(l).Log("msg", "Alertmanager is moving to a new parser for labels and matchers, and this input is incompatible. Alertmanager has instead parsed the input using the old matchers parser as a fallback. To make this input compatible with the new parser please make sure all regular expressions and values are double-quoted. If you are still seeing this message please open an issue.", "input", input, "origin", origin, "err", nErr, "suggestion", suggestion) return cMatcher, nil } // If the input is valid in both parsers, but produces different results, @@ -219,7 +219,7 @@ func FallbackMatchersParser(l log.Logger, m *Metrics) ParseMatchers { suggestion := sb.String() // The input is valid in the pkg/labels parser, but not the // new matchers/parse parser. - level.Warn(l).Log("msg", "Alertmanager is moving to a new parser for labels and matchers, and this input is incompatible. Alertmanager has instead parsed the input using the old matchers parser as a fallback. To make this input compatible with the new parser please make sure all regular expressions and values are double-quoted. If you are still seeing this message please open an issue.", "input", input, "origin", origin, "err", err, "suggestion", suggestion) + level.Warn(l).Log("msg", "Alertmanager is moving to a new parser for labels and matchers, and this input is incompatible. Alertmanager has instead parsed the input using the old matchers parser as a fallback. To make this input compatible with the new parser please make sure all regular expressions and values are double-quoted. If you are still seeing this message please open an issue.", "input", input, "origin", origin, "err", nErr, "suggestion", suggestion) return cMatchers, nil } // If the input is valid in both parsers, but produces different results,