刚接手elk就被这个问题困惑过,或许仔细阅读官方文档是最佳方式
提到的场景,Filebeat 虽然能读取不同的日志目录,但是在 Logstash 这边,或者是 Elasticsearch 这边,怎么区分不同 application server 的日志数据呢?
解决方案:Filebeat 的配置项 fields 或者 配置tags 可以实现不同日志来源的区分
filebeat.yml
tags: ["tomcat-a"]
fields:
log_source: tomcat-a
在logstash添加判断条件
if "tomcat-a" in [tags] {
elasticsearch {
hosts => ["localhost:9200"]
index => "log1-%{index_date}"
}
}