From 4b867c55cb031b1a8c4b90de257b07b7401eb04c Mon Sep 17 00:00:00 2001 From: Eric Miller Date: Mon, 27 Nov 2023 14:43:58 -0600 Subject: [PATCH 1/2] fix(inputs.tail): If permission denied delete old tailer --- plugins/inputs/tail/tail.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/inputs/tail/tail.go b/plugins/inputs/tail/tail.go index 4bdeb5eb0f8d8..ebab3eacb83e6 100644 --- a/plugins/inputs/tail/tail.go +++ b/plugins/inputs/tail/tail.go @@ -236,6 +236,10 @@ func (t *Tail) tailNewFiles(fromBeginning bool) error { if err := tailer.Err(); err != nil { t.Log.Errorf("Tailing %q: %s", tailer.Filename, err.Error()) + if strings.HasSuffix(err.Error(), "permission denied") { + t.Log.Errorf("Deleting tailer for %q", tailer.Filename) + delete(t.tailers, tailer.Filename) + } } }() From 264219c1ec798565d5930e5a45f65a260509937e Mon Sep 17 00:00:00 2001 From: Eric Miller Date: Thu, 30 Nov 2023 13:28:26 -0600 Subject: [PATCH 2/2] Single log, containing error in either case --- plugins/inputs/tail/tail.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/inputs/tail/tail.go b/plugins/inputs/tail/tail.go index ebab3eacb83e6..ecb9b9442c99d 100644 --- a/plugins/inputs/tail/tail.go +++ b/plugins/inputs/tail/tail.go @@ -235,10 +235,11 @@ func (t *Tail) tailNewFiles(fromBeginning bool) error { t.Log.Debugf("Tail removed for %q", tailer.Filename) if err := tailer.Err(); err != nil { - t.Log.Errorf("Tailing %q: %s", tailer.Filename, err.Error()) if strings.HasSuffix(err.Error(), "permission denied") { - t.Log.Errorf("Deleting tailer for %q", tailer.Filename) + t.Log.Errorf("Deleting tailer for %q due to: %v", tailer.Filename, err) delete(t.tailers, tailer.Filename) + } else { + t.Log.Errorf("Tailing %q: %s", tailer.Filename, err.Error()) } } }()