日志采集器选择
常见的日志采集工具:Logstash、Filebeat、Fluentd、Fluent Bit、Logagent、logtail、rsyslog、syslog-ng
我们对比其中常用的Logstash、Filebeat、Fluentd、Fluent Bit来进行选择
logstash | filebeat | Fluentd | Fluent Bit | |
scope | containers/servers | containers/servers | containers/servers | containers/servers |
Language | Jruby | Golang | C&Ruby | C |
Memory | ~400MB | ~20MB | ~40MB | ~450KB |
Performance | High Performance | High Performance | High Performance | High Performance |
Dependencies | jdk | 零依赖,某些插件可能需要依赖 | 依赖gem | 零依赖,某些插件可能需要依赖 |
Plugins | 1k+插件,功能丰富 | 1k+插件,功能丰富 | 650+插件可用 | 大约35插件可用 |
License | Elastic | Elastic | Apache License v2.0 | Apache License v2.0 |
logstash比较重量级,而且对jdk有强依赖,在做选型的时候,需要特别留意他的资源消耗,基本上可消耗内存在400M以上,cpu 达1G左右
配置:
input {
file {
path => ["/data/log/**/*.log"] ###这里递归匹配目录及其子目录
start_position=>"beginning"
}
}
output {
stdout {
codec => rubydebug
}
}
filebeat:
没有依赖,资源消耗相对比较少,但是场景比较受限,和ELK集成最佳
filebeat.inputs:
- type: log
enabled: true
paths:
- /data/log/**/*.log
output.kafka:
enable: true
hosts: ["主机1:9092","主机2:9092","主机3:9092"]
topic: "test_filebeat"