加载中

配置输入

提示

Filebeat 模块为常见日志格式提供了最快的上手体验。请参阅 快速入门:安装与配置 以了解如何开始。

要手动配置 Filebeat(而不是使用 模块),你需要在 filebeat.ymlfilebeat.inputs 部分中指定一个输入列表。输入指定了 Filebeat 如何定位和处理输入数据。

该列表是一个 YAML 数组,因此每个输入都以短横线(-)开头。你可以指定多个输入,并且可以多次指定相同的输入类型。例如

filebeat.inputs:
- type: filestream
  id: my-filestream-id
  paths:
    - /var/log/system.log
    - /var/log/wifi.log
- type: filestream
  id: apache-filestream-id
  paths:
    - "/var/log/apache2/*"
  fields:
    apache: true
  fields_under_root: true
		
  1. 每个 filestream 输入必须具有唯一的 ID,以便跟踪文件的状态。

对于最基本的配置,定义一个具有单个路径的单个输入。例如

filebeat.inputs:
- type: filestream
  id: my-filestream-id
  paths:
    - /var/log/*.log
		

此示例中的输入会收集路径 /var/log/*.log 中的所有文件,这意味着 Filebeat 将收集 /var/log/ 目录下以 .log 结尾的所有文件。这里还支持由 Go Glob 支持的所有模式。

要从预定义级别的子目录中获取所有文件,请使用此模式:/var/log/*/*.log。这将从 /var/log 的子文件夹中获取所有 .log 文件。它不会从 /var/log 文件夹本身获取日志文件。目前无法递归获取目录的所有子目录中的所有文件。

你可以将 Filebeat 配置为使用以下输入

© . This website operates independently and is not affiliated with or endorsed by Elasticsearch B.V. All brand names, logos, and trademarks are the property of their respective owners.