From be1dc49ad9384e28a067a2c9134b9192100eca35 Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Fri, 24 Apr 2020 16:40:08 -0700 Subject: [PATCH] Document distinction between file and tail inputs (#7353) --- plugins/inputs/file/README.md | 21 ++++++++++----------- plugins/inputs/file/file.go | 12 ++++-------- plugins/inputs/tail/tail.go | 2 +- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/plugins/inputs/file/README.md b/plugins/inputs/file/README.md index 24139973b..ef0fb90b0 100644 --- a/plugins/inputs/file/README.md +++ b/plugins/inputs/file/README.md @@ -1,22 +1,18 @@ # File Input Plugin -The file plugin updates a list of files every interval and parses the contents -using the selected [input data format](/docs/DATA_FORMATS_INPUT.md). +The file plugin parses the **complete** contents of a file **every interval** using +the selected [input data format][]. -Files will always be read in their entirety, if you wish to tail/follow a file -use the [tail input plugin](/plugins/inputs/tail) instead. +**Note:** If you wish to parse only newly appended lines use the [tail][] input +plugin instead. ### Configuration: ```toml [[inputs.file]] - ## Files to parse each interval. - ## These accept standard unix glob matching rules, but with the addition of - ## ** as a "super asterisk". ie: - ## /var/log/**.log -> recursively find all .log files in /var/log - ## /var/log/*/*.log -> find all .log files with a parent dir in /var/log - ## /var/log/apache.log -> only read the apache log file - files = ["/var/log/apache/access.log"] + ## Files to parse each interval. Accept standard unix glob matching rules, + ## as well as ** to match recursive files and directories. + files = ["/tmp/metrics.out"] ## Data format to consume. ## Each data format has its own unique set of configuration options, read @@ -28,3 +24,6 @@ use the [tail input plugin](/plugins/inputs/tail) instead. ## to disable. # file_tag = "" ``` + +[input data format]: /docs/DATA_FORMATS_INPUT.md +[tail]: /plugins/inputs/tail diff --git a/plugins/inputs/file/file.go b/plugins/inputs/file/file.go index 860595283..fe2a840fa 100644 --- a/plugins/inputs/file/file.go +++ b/plugins/inputs/file/file.go @@ -20,13 +20,9 @@ type File struct { } const sampleConfig = ` - ## Files to parse each interval. - ## These accept standard unix glob matching rules, but with the addition of - ## ** as a "super asterisk". ie: - ## /var/log/**.log -> recursively find all .log files in /var/log - ## /var/log/*/*.log -> find all .log files with a parent dir in /var/log - ## /var/log/apache.log -> only read the apache log file - files = ["/var/log/apache/access.log"] + ## Files to parse each interval. Accept standard unix glob matching rules, + ## as well as ** to match recursive files and directories. + files = ["/tmp/metrics.out"] ## The dataformat to be read from files ## Each data format has its own unique set of configuration options, read @@ -45,7 +41,7 @@ func (f *File) SampleConfig() string { } func (f *File) Description() string { - return "Reload and gather from file[s] on telegraf's interval." + return "Parse a complete file each interval" } func (f *File) Gather(acc telegraf.Accumulator) error { diff --git a/plugins/inputs/tail/tail.go b/plugins/inputs/tail/tail.go index 9e7d6ecf1..02d35c95b 100644 --- a/plugins/inputs/tail/tail.go +++ b/plugins/inputs/tail/tail.go @@ -100,7 +100,7 @@ func (t *Tail) SampleConfig() string { } func (t *Tail) Description() string { - return "Stream a log file, like the tail -f command" + return "Parse the new lines appended to a file" } func (t *Tail) Init() error {