From 3d2b7bd210356c20701ce51eaf60480b314ad1c8 Mon Sep 17 00:00:00 2001 From: Sven Rebhan <36194019+srebhan@users.noreply.github.com> Date: Thu, 8 Sep 2022 21:55:24 +0200 Subject: [PATCH] fix: Do not error out for parsing errors in datadog mode. (#11777) --- plugins/inputs/statsd/statsd.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/inputs/statsd/statsd.go b/plugins/inputs/statsd/statsd.go index a4e0431f3..eef1eb4be 100644 --- a/plugins/inputs/statsd/statsd.go +++ b/plugins/inputs/statsd/statsd.go @@ -516,15 +516,19 @@ func (s *Statsd) parser() error { case line == "": case s.DataDogExtensions && strings.HasPrefix(line, "_e"): if err := s.parseEventMessage(in.Time, line, in.Addr); err != nil { - return err + // Log the line causing the parsing error and continue + // with the next line to not stop the whole gathering + // process. + s.Log.Errorf("Parsing line failed: %v", err) + s.Log.Debugf(" line was: %s", line) } default: if err := s.parseStatsdLine(line); err != nil { - if errors.Cause(err) == errParsing { - // parsing errors log when the error occurs - continue + if errors.Cause(err) != errParsing { + // Ignore parsing errors but error out on + // everything else... + return err } - return err } } }