Filebeat 是一个轻量级的日志收集器,用于将日志数据发送到 Elasticsearch 或 Logstash 进行存储和分析。在 Ubuntu 系统中,Filebeat 的配置文件通常位于 /etc/filebeat/filebeat.yml
。下面是对该配置文件的一些主要部分的解析:
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
这里,Filebeat 将收集 /var/log
目录下的所有 .log
文件。
filebeat.modules:
path: ${config.home}/modules.d/*.yml
reload.enabled: false
这里,Filebeat 将加载 /etc/filebeat/modules.d
目录下的所有 .yml
模块配置文件。
output.elasticsearch:
hosts: ["localhost:9200"]
这里,Filebeat 将日志数据发送到本地的 Elasticsearch 服务器(地址为 localhost
,端口为 9200
)。
setup.template.settings:
index.number_of_shards: 3
index.codec: best_compression
_source.enabled: true
这里,设置了 Elasticsearch 索引的分片数为 3,使用了最佳压缩编解码器,并启用了 _source
字段。
setup.template.name: "filebeat"
这里,索引模板的名称为 filebeat
。
setup.template.pattern: "filebeat-*"
这里,索引模板匹配以 filebeat-
开头的索引名称。
这些只是 Filebeat 配置文件中的一部分选项。你可以根据自己的需求修改这些选项,以满足实际的日志收集和处理需求。更多关于 Filebeat 配置文件的详细信息,请参考官方文档:https://www.elastic.co/guide/en/beats/filebeat/current/configuration-file.html