From e4d7be0f2b5c37d60d2d6e7e7df4f8f3c97f2e45 Mon Sep 17 00:00:00 2001 From: ericmiller-wpengine <98620334+ericmiller-wpengine@users.noreply.github.com> Date: Thu, 30 Nov 2023 16:52:28 -0600 Subject: [PATCH] fix(inputs.tail): Retry opening file after permission denied (#14357) --- plugins/inputs/tail/tail.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/inputs/tail/tail.go b/plugins/inputs/tail/tail.go index 4bdeb5eb0f8d8..ecb9b9442c99d 100644 --- a/plugins/inputs/tail/tail.go +++ b/plugins/inputs/tail/tail.go @@ -235,7 +235,12 @@ 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 due to: %v", tailer.Filename, err) + delete(t.tailers, tailer.Filename) + } else { + t.Log.Errorf("Tailing %q: %s", tailer.Filename, err.Error()) + } } }()