filebeat

Filebeat 日志采集器

补充说明

filebeat 轻量采集文件和容器日志,转发到 Elasticsearch、Logstash 或 Kafka。它记录读取位置(registry),支持多行合并和模块化采集。

常用示例

filebeat -e -c filebeat.yml
filebeat test config -c filebeat.yml
filebeat test output -c filebeat.yml
filebeat modules enable nginx
filebeat setup -e
filebeat export config

filebeat.yml:

filebeat.inputs:
  - type: filestream
    id: app-logs
    paths:
      - /var/log/app/*.log
    parsers:
      - multiline:
          type: pattern
          pattern: '^\d{4}-\d{2}-\d{2}'
          negate: true
          match: after

output.elasticsearch:
  hosts: ["http://es:9200"]

易错点与排错

相关命令

读完自测

合上页面,先回答,再展开对照。

  1. 删除 registry 会发生什么?
  2. 多行日志被拆成多条,先查什么?
  3. 采集端看似正常但输出端没有数据,先查什么?
答案
  1. 会导致重复采集或从头读取。
  2. 多行日志配置,先拿样本验证。
  3. 输出端是否阻塞或报错,关注队列、丢弃计数和 output 错误。