logstash接受checkpoint防火墙日志并用ruby分词
阅读原文时间:2023年07月08日阅读:1

直接上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}"
        }
}

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章