How can filebeat collect multiple log files?

Filebeat can collect multiple log files by configuring multiple inputs.

  1. YAML configuration file for Filebeat
  2. inputs in filebeat
  3. Write it in English.
  4. ways
  5. You can customize additional parameters for each input block as needed, such as the encoding of log files and excluding certain files.
  6. Save and close the configuration file.
  7. 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.

bannerAds