Skip to content

Commit

Permalink
Add warning when file input has no matches
Browse files Browse the repository at this point in the history
  • Loading branch information
camdencheek committed Jul 9, 2020
1 parent 8b756aa commit 9b74136
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions plugin/builtin/input/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func (f *FileInput) Start() error {
return
case <-globTicker.C:
matches := getMatches(f.Include, f.Exclude)
f.warnIfNoMatches(matches, firstCheck)
for _, match := range matches {
f.checkFile(ctx, match, firstCheck)
}
Expand All @@ -205,6 +206,15 @@ func (f *FileInput) Start() error {
return nil
}

func (f *FileInput) warnIfNoMatches(matches []string, firstCheck bool) {
if firstCheck && len(matches) == 0 {
f.Warnw(
"no files match the configured include patterns",
"include", f.Include,
)
}
}

func (f *FileInput) Stop() error {
f.cancel()
f.wg.Wait()
Expand Down

0 comments on commit 9b74136

Please sign in to comment.