首页 文章

如何使用grok过滤器获取tomcat日志中匹配的消息?

提问于
浏览
1

我在tomcat日志中获得了不同的不同信息 . 我只想要带有“Server startup in”消息的行 . 我在logstash中使用了grok过滤器,但我无法获得带有该消息的唯一一条过滤消息 . 我收到了tomcat日志中的所有消息 . logstash中的conf文件是......

input {
  stdin { }
  file {
    type => "tomcat-access"
    path => ["D:/apache-tomcat-7/logs/catalina.2015-05-19.log"]
  }
}

filter {
    grok {
match => [ "message:Server startup in", "%{SYSLOGBASE} %{DATA:message}"]
  }
}

output {
    stdout { codec => rubydebug }
  elasticsearch {
    index => "tomcat"
    cluster => "cloud-es"
  }

}

1 回答

  • 0

    grok filter用于从消息中提取字段 . 它不做任何过滤 . 你应该使用conditionaldrop filter

    filter {
      if [message] !~ /Server start up in/ {
        drop { }
      }
    }
    

    要么:

    filter {
      if "Server start up in" not in [message] {
        drop { }
      }
    }
    

相关问题