Filebeat日志聚合实操指南
一 概念与目标
二 快速落地步骤
三 关键配置示例
filebeat.inputs:
- type: log
enabled: true
paths:
- G:/log/*.log
multiline:
pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2}'
negate: true
match: after
max_lines: 1000
timeout: 3s
output.elasticsearch:
hosts: ["127.0.0.1:9200"]
index: "actionlog-%{+yyyy.MM}"
filebeat.inputs:
- type: log
enabled: true
paths:
- G:/log/*.log
multiline:
pattern: '^<[0-9]+'
negate: true
match: after
timeout: 10s
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/sys.log
include_lines: ["WARN", "ERR", "sshd"]
output.elasticsearch:
hosts: ["172.16.1.161:9200","172.16.1.162:9200","172.16.1.163:9200"]
index: "system-%{[agent.version]}-%{+yyyy.MM.dd}"
output.elasticsearch:
hosts: ["localhost:9200"]
index: "filebeat-%{[agent.version]}-%{+yyyy.MM.dd}"
output.logstash:
hosts: ["localhost:5044"]
output.redis:
hosts: ["10.0.0.7"]
db: 1
port: 6379
password: "123"
key: "filesystem-log-5612"
filebeat.inputs:
- type: log
enabled: true
scan_frequency: 10s
close_eof: true
close_older: 1m
force_close_files: true
paths:
- G:/log/*.log
以上示例覆盖了多行合并、行过滤、以及直写 Elasticsearch、经 Logstash、写入 Redis 的常见用法,并给出“只读取一次”的优化参数,便于按场景快速落地。
四 性能与可靠性建议