grok样例-01

input {

    file {

      type=> “nginx-acc”

      path=> ["acclogpath"]

      }

    file {

      type=> “nginx-error”

      path=> ["errorlogpath"]

      }

  }

 

 

filter {

  if [type] == "nginx-acc" {

    grok {

      match => ["message","%{IPORHOST:source_ip} - - \[%{HTTPDATE:timestamp}\] %{NUMBER:url_time_request:float} \"%{NOTSPACE:method} \" ,,,"]

    }

    mutate {

      remove_field => ["message"]

    }

  }

 

if [type] == "nginx-error" {

    grok {

      match => ["message","%{DATESTAMP:timestamp} %{GREEDYDATA:random} client:%{GREEDYDATA:client} server:%{GREEDYDATA:server}"]

    }

    mutate {

      remove_field => ["message"]

    }

  }

}

 

 

output {

  elasticsearch{

  hosts => ["elasticsearch_service_ip"]

  index => "logstash-%{+YYYY.MM.dd}"

  }

}

 

在没有好的办法匹配使用下GREEDYDATA,从后边开始匹配

posted @ 2020-09-03 20:27  winss  阅读(187)  评论(0)    收藏  举报