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}
}

 

posted on 2017-03-16 19:57  肖建锋  阅读(1799)  评论(0编辑  收藏  举报