logstash收集时filebeat区分日志

logstash收集时filebeat区分日志

 

1.场景

filebeat在服务器中同时收集nginx和web项目日志,须要对两个日志在logstash中分别处理nginx

2.版本区别

==6.x以前==的能够使用filebeat的prospectors里面配置document_type类型,而后在logstash里面使用if [type] == “string” 来匹配,这里不作详细记录
==6.x以后==配置文件不支持document_type,也就是说旧方法是失效的,目前我使用的是==6.2.3==版本的filebeatweb

3.解决方法

在filebeat里面新增一个fields字段,对这个字段作记录而后在logstahs中进行区分apache

filebeat配置

filebeat.prospectors:

- type: log

  paths:
    - /Library/apache-tomcat-8.5.15/bin/logs/web.log
    #- c:\programdata\elasticsearch\logs\*

  fields: 
    document_type: weblog   #这一行的key:value均可以本身定义

logstash配置

output{
    if[fields][document_type] == "weblog" {
        stdout { codec => rubydebug }  
    }
}
相关文章
相关标签/搜索