2018-06-22 01:02:34 +00:00
|
|
|
# Tail Input Plugin
|
2016-04-22 21:47:26 +00:00
|
|
|
|
|
|
|
The tail plugin "tails" a logfile and parses each log message.
|
|
|
|
|
|
|
|
By default, the tail plugin acts like the following unix tail command:
|
|
|
|
|
|
|
|
```
|
2016-04-26 16:43:41 +00:00
|
|
|
tail -F --lines=0 myfile.log
|
2016-04-22 21:47:26 +00:00
|
|
|
```
|
|
|
|
|
2016-04-26 16:43:41 +00:00
|
|
|
- `-F` means that it will follow the _name_ of the given file, so
|
|
|
|
that it will be compatible with log-rotated files, and that it will retry on
|
|
|
|
inaccessible files.
|
2016-04-22 21:47:26 +00:00
|
|
|
- `--lines=0` means that it will start at the end of the file (unless
|
|
|
|
the `from_beginning` option is set).
|
|
|
|
|
|
|
|
see http://man7.org/linux/man-pages/man1/tail.1.html for more details.
|
|
|
|
|
|
|
|
The plugin expects messages in one of the
|
|
|
|
[Telegraf Input Data Formats](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md).
|
|
|
|
|
2020-03-27 22:40:08 +00:00
|
|
|
### Configuration
|
2016-04-22 21:47:26 +00:00
|
|
|
|
|
|
|
```toml
|
|
|
|
[[inputs.tail]]
|
2020-03-27 22:40:08 +00:00
|
|
|
## File names or a pattern to tail.
|
2016-04-26 16:43:41 +00:00
|
|
|
## 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" -> just tail the apache log file
|
|
|
|
##
|
|
|
|
## See https://github.com/gobwas/glob for more examples
|
|
|
|
##
|
|
|
|
files = ["/var/mymetrics.out"]
|
2020-03-27 22:40:08 +00:00
|
|
|
|
2016-04-26 16:43:41 +00:00
|
|
|
## Read file from beginning.
|
2020-03-27 22:40:08 +00:00
|
|
|
# from_beginning = false
|
|
|
|
|
2016-12-16 14:01:49 +00:00
|
|
|
## Whether file is a named pipe
|
2020-03-27 22:40:08 +00:00
|
|
|
# pipe = false
|
2016-04-26 16:43:41 +00:00
|
|
|
|
2017-09-11 18:56:04 +00:00
|
|
|
## Method used to watch for file updates. Can be either "inotify" or "poll".
|
|
|
|
# watch_method = "inotify"
|
|
|
|
|
2020-03-27 22:40:08 +00:00
|
|
|
## Maximum lines of the file to process that have not yet be written by the
|
|
|
|
## output. For best throughput set based on the number of metrics on each
|
|
|
|
## line and the size of the output's metric_batch_size.
|
|
|
|
# max_undelivered_lines = 1000
|
|
|
|
|
2016-04-26 16:43:41 +00:00
|
|
|
## Data format to consume.
|
2017-04-27 21:59:18 +00:00
|
|
|
## Each data format has its own unique set of configuration options, read
|
2016-04-26 16:43:41 +00:00
|
|
|
## more about them here:
|
|
|
|
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
|
|
|
|
data_format = "influx"
|
2016-04-22 21:47:26 +00:00
|
|
|
```
|
|
|
|
|
2020-03-27 22:40:08 +00:00
|
|
|
### Metrics
|
2018-06-22 01:02:34 +00:00
|
|
|
|
|
|
|
Metrics are produced according to the `data_format` option. Additionally a
|
|
|
|
tag labeled `path` is added to the metric containing the filename being tailed.
|