logstash

作者: J书越来越垃圾了 | 来源:发表于2017-10-22 18:02 被阅读17次

不建议阅读.个人备忘

配置文件(redis)

主要分三大块,input,filter,output,三块为同一级

input {
    redis {
        host => '10.1.27.31'
        data_type => 'list'
        key => 'network'
    }
#这里的key值,来源与filebeat采集是output时的定义.
    redis {
        host => '10.1.27.31'
        data_type => 'list'
        key => 'nginx-202'
    }
}


filter {
    if [type] == '93.218-zabbix' {
#这里的type来源于filebeat采集时input中的定义(document_type)
        grok{
            match => {
                "message" => "%{IP:clientIP}\|%{IP:serverIP}\|%{DATA:req_addr}\|%{DATA:req_url}\|%{DATA:req_status}\|%{DATA:req_browder}\|%{DATA:req_duration}\|%{DATA:req_user}"
           }
        }
    }
#这里的match要根据日志格式进行匹配,这个主要是Nginx的日志
#Nginx中对日志进行了自定的格式化.nginx参考格式
#'$remote_addr|$http_host|$request|$http_referer|$status|$http_user_agent|$request_time|$remote_user';


    if [type] == '93.218-it' {
        grok{
            match => {
                "message" => "%{IP:clientIP}\|%{IP:serverIP}\|%{DATA:req_addr}\|%{DATA:req_status}\|%{DATA:req_browder}\|%{DATA:req_duration}\|%{DATA:req_user}"
           }
        }
    }
#同上,参考格式
#'$remote_addr|$http_host|$request|$status|$http_user_agent|$request_time|$remote_user';
}


#通过type判断,定义不同的index,kibana就能建立不同的map
output {
    if [type] == '93.218-zabbix' {
        elasticsearch {
            hosts => '10.1.27.31'
            codec => 'json'
            index => '93.218-zabbix-%{+YYYY.MM.dd}'
        }
    }
    if [type] == '93.218-it' {
        elasticsearch {
            hosts => '10.1.27.31'
            codec => 'json'
            index => '93.218-it-%{+YYYY.MM.dd}'
        }
    }
}

过滤做好之后,可根据match的字段进行匹配,看自己想看的结果,以及后续的画图等

kibana.jpg

相关文章

网友评论

      本文标题:logstash

      本文链接:https://www.haomeiwen.com/subject/ojtnuxtx.html