How can filebeat collect multiple log files?
Filebeat can collect multiple log files by configuring multiple inputs.
- YAML configuration file for Filebeat
- inputs in filebeat
- Write it in English.
- ways
- You can customize additional parameters for each input block as needed, such as the encoding of log files and excluding certain files.
- Save and close the configuration file.
- Start or restart Filebeat, it will begin collecting all the log files specified in the configuration file.
Here is an example configuration file that collects two log files:
filebeat.inputs:
- type: log
paths:
- /var/log/app1/*.log
exclude_files: ['.gz$']
- type: log
paths:
- /var/log/app2/*.log
encoding: utf-8
In the example above, there are two input configuration blocks under filebeat.inputs, each corresponding to all .log files in the directories /var/log/app1/ and /var/log/app2/. The first block excludes files ending in .gz, while the second block specifies the encoding of the log files as UTF-8.
Note: each input configuration block can have its own set of parameters, which can be configured as needed.