2018-07-14 14:22:59 +08:00
|
|
|
# File Input Plugin
|
|
|
|
|
|
2022-06-08 05:37:08 +08:00
|
|
|
The file plugin parses the **complete** contents of a file **every interval**
|
|
|
|
|
using the selected [input data format][].
|
2018-07-14 14:22:59 +08:00
|
|
|
|
2020-04-25 07:40:08 +08:00
|
|
|
**Note:** If you wish to parse only newly appended lines use the [tail][] input
|
|
|
|
|
plugin instead.
|
2018-07-14 14:22:59 +08:00
|
|
|
|
2022-10-27 03:58:36 +08:00
|
|
|
## Global configuration options <!-- @/docs/includes/plugin_config.md -->
|
|
|
|
|
|
|
|
|
|
In addition to the plugin-specific configuration settings, plugins support
|
|
|
|
|
additional global and plugin configuration settings. These settings are used to
|
|
|
|
|
modify metrics, tags, and field or create aliases and configure ordering, etc.
|
|
|
|
|
See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
|
|
|
|
|
2023-01-12 23:55:21 +08:00
|
|
|
[CONFIGURATION.md]: ../../../docs/CONFIGURATION.md#plugins
|
2022-10-27 03:58:36 +08:00
|
|
|
|
2021-11-25 02:56:26 +08:00
|
|
|
## Configuration
|
2019-11-14 05:00:41 +08:00
|
|
|
|
2022-05-24 21:49:47 +08:00
|
|
|
```toml @sample.conf
|
2022-04-08 06:01:21 +08:00
|
|
|
# Parse a complete file each interval
|
2018-07-14 14:22:59 +08:00
|
|
|
[[inputs.file]]
|
2020-04-25 07:40:08 +08:00
|
|
|
## Files to parse each interval. Accept standard unix glob matching rules,
|
|
|
|
|
## as well as ** to match recursive files and directories.
|
|
|
|
|
files = ["/tmp/metrics.out"]
|
2018-07-14 14:22:59 +08:00
|
|
|
|
2022-04-08 06:01:21 +08:00
|
|
|
## Character encoding to use when interpreting the file contents. Invalid
|
|
|
|
|
## characters are replaced using the unicode replacement character. When set
|
|
|
|
|
## to the empty string the data is not decoded to text.
|
|
|
|
|
## ex: character_encoding = "utf-8"
|
|
|
|
|
## character_encoding = "utf-16le"
|
|
|
|
|
## character_encoding = "utf-16be"
|
|
|
|
|
## character_encoding = ""
|
|
|
|
|
# character_encoding = ""
|
|
|
|
|
|
2018-07-14 14:22:59 +08:00
|
|
|
## Data format to consume.
|
|
|
|
|
## Each data format has its own unique set of configuration options, read
|
|
|
|
|
## more about them here:
|
|
|
|
|
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
|
|
|
|
|
data_format = "influx"
|
2019-11-14 05:00:41 +08:00
|
|
|
|
2021-11-25 02:56:26 +08:00
|
|
|
|
2019-11-14 05:00:41 +08:00
|
|
|
## Name a tag containing the name of the file the data was parsed from. Leave empty
|
2021-11-25 02:56:26 +08:00
|
|
|
## to disable. Cautious when file name variation is high, this can increase the cardinality
|
|
|
|
|
## significantly. Read more about cardinality here:
|
2021-10-08 04:38:20 +08:00
|
|
|
## https://docs.influxdata.com/influxdb/cloud/reference/glossary/#series-cardinality
|
2019-11-14 05:00:41 +08:00
|
|
|
# file_tag = ""
|
2018-07-14 14:22:59 +08:00
|
|
|
```
|
2020-04-25 07:40:08 +08:00
|
|
|
|
2022-06-08 05:37:08 +08:00
|
|
|
## Metrics
|
|
|
|
|
|
|
|
|
|
The format of metrics produced by this plugin depends on the content and data
|
|
|
|
|
format of the file.
|
|
|
|
|
|
2020-04-25 07:40:08 +08:00
|
|
|
[input data format]: /docs/DATA_FORMATS_INPUT.md
|
|
|
|
|
[tail]: /plugins/inputs/tail
|
2023-02-09 18:04:41 +08:00
|
|
|
|
|
|
|
|
## Example Output
|