logstash 切分tomcat日志

以下配置是logstash切分tomcat catalina.out日志。

http://grok.qiexun.net/  分割时先用这个网站测试下语句对不对,能不能按需切割日志。

input {
  file {
    type => "01-catalina"
    path => ["/data1/application/cs/tomcat-1/logs/catalina.out"]
    start_position => "beginning"
    ignore_older => 3
    codec=> multiline {      
      pattern => "^2018"  
      negate => true
      what => "previous"
            }
    }

  file {
    type => "02-catalina"
    path => ["/data1/application/cs/tomcat-2/logs/catalina.out"]
    start_position => "beginning"
    ignore_older => 3
    codec=> multiline {
      pattern => "^2018"
      negate => true
      what => "previous"
            }
    }

}

filter {
  grok {
  match => {
    "message" => "%{DATESTAMP:date} \|-%{LOGLEVEL:level} \[%{DATA:class}\] %{DATA:code_info} -\| %{GREEDYDATA:log_info}"
      }
    }
  }

output {
  elasticsearch {
    hosts => ["10.139.48.144:9200"]
    index => "jx-cs-tomcat-%{type}"
        }
stdout {
  codec => rubydebug
   }
  }

猜你喜欢

转载自www.cnblogs.com/abkn/p/9267166.html