logstash 解析日志文件


input {
  file {
    path => "/usr/local/test/log.log"
  }

}
filter {
    grok {
match => { "message" => "%{TIMESTAMP_ISO8601:time} %{NUMBER:total_time} (?<req_id>([0-9a-zA-Z]*)) --app (?<app_id>([0-9a-zA-Z]*)) %{IP:ip} (?<req_port>([0-9]*)|[\s\S])
 %{WORD:method} %{URIPATHPARAM:req_path} %{NUMBER:resp_code} --svc (?<svc_id>([0-9a-zA-Z]*)) (?<sub_services>[\s\S]*)"}
    }
ruby{
code => "
            array=event.get('sub_services').split(']')
            index=0 
            array.each do |value|
                index=index+1
                tem='service'+index.to_s
                value=value+']'
                event.set(tem,value)
            end
        "
}
}
output {
         mongodb{
        collection => "testlog"
        database => "test"        
        uri => "mongodb://192.168.1.203:27017"

    }
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM