C/C++教程

logstash接受checkpoint防火墙日志并用ruby分词

本文主要是介绍logstash接受checkpoint防火墙日志并用ruby分词,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

直接上logstahs配置文件

input{
    syslog{
    type => "syslog"
    port => 514
    }
}
filter {
    grok {
      match => {
                "message" => "\[%{DATA:log}\"\]"
         }
}
    ruby {
                code => "
                        array1 = event.get('log').split(%r{\";\s})
                        array1.each do |temp1|
                                if temp1.nil? then
                                        next
                                end
                                array2 = temp1.split(':')
                                key = array2[0]
                                value = array2[1]
                                if key.nil? then
                                        next
                                end
                                event.set(key, value)
                        end
                "
                remove_field => [ "log" ]
        }
}
output {
    elasticsearch {
        hosts => "elastic:9200"
        user => "elastic"
        password => "*****"
        index => "smc-%{+yyyy.MM.dd}"
        }
}
这篇关于logstash接受checkpoint防火墙日志并用ruby分词的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!