Filebeat支持的日志格式与解析能力
一 内置解析器与容器日志
二 模块生态覆盖的常见服务日志 Filebeat 提供丰富的官方模块(modules),开箱即用地解析并可视化常见服务日志,典型包括:Nginx、Apache、MySQL、Kafka 等。模块通常包含:默认日志路径、必要的多行合并、Elasticsearch Ingest Pipeline(字段类型与解析)、以及 Kibana 仪表板。以 Nginx 为例,模块内置对 access 与 error 的解析与展示能力。
三 通用文本与正则场景
四 快速配置示例
filebeat.inputs:
- type: filestream
id: app-json
paths:
- /var/log/app/*.log
parsers:
- json:
keys_under_root: true
overwrite_keys: true
add_error_key: true
filebeat.inputs:
- type: filestream
id: k8s-container
paths:
- /var/log/containers/*.log
parsers:
- container:
stream: stdout
filebeat.inputs:
- type: filestream
id: syslog
paths:
- /var/log/syslog
parsers:
- syslog:
format: rfc5424
timezone: America/Chicago
log_errors: true
filebeat.inputs:
- type: filestream
id: tomcat-error
paths:
- /opt/tomcat/logs/catalina.out
multiline:
pattern: '^\['
negate: true
match: after
上述示例覆盖了 JSON、容器、syslog 与 多行 等常见场景,可按实际日志格式组合使用。