grok 匹配log4j


input {
    file {
       codec => multiline {
           pattern => "^\[2016"
           negate => true
           what => previous
          }
       type => "log4j" 
       path => "/usr/local/soft/logs/*.log"
    }
}
filter {
    grok {
               match => {
                    "message" => "\[(?<CreatedOn>[0-9]{4}-[0-9]{2}-[0-9]{2}\s[0-9]{2}:[0-9]{2}:[0-9]{2}) (?<ErrorLevel>\w+)\] \[(?<TargetMethod>.*)\] \((?<TargetClass>.*)\) - (?<Message>(\w|\s)*)\r\n(?<Stack>.*)"
            }
    }
    mutate {
        rename => { "host" => "ServerIP"}
        remove_field => ["message","tags"]
    }
    }
output {
    elasticsearch {
            hosts => ["114.215.171.188:9200"]
            index=>"logstash-%{type}"  #%{type}-%{+YYYY.MM.dd}
            document_type=>"%{type}"
        }
    stdout{codec=>rubydebug}
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM