【问题标题】:logstash grok filter pattern not found未找到 logstash grok 过滤器模式
【发布时间】:2015-04-14 19:46:12
【问题描述】:

我一直在尝试为 logstash 创建一些自定义的 grok 模式。他们中的大多数工作正常,但有一个让我难过。模式是:

WINUSER (?<=User:\s)\w+ 

这是正在搜索的数据示例:

2015-04-14 14:06:18 exchange.ows1.osborneit.com INFO 1149 NT AUTHORITY\NETWORK SERVICE Remote Desktop Services: User authentication succeeded:

User: administrator
Domain: .
Source Network Address: 172.24.1.32

我在http://grokconstructor.appspot.com/do/match 上对此进行了测试,它工作正常,但logstash 似乎忽略了它。我似乎无法弄清楚我做错了什么。

下面是我的logstash配置:

input {
   udp {
      type => "eventlog"
      codec => json
      port => 5140
   tags => ['windows', 'eventlog']
   }
}
filter {
  if [type] == "eventlog" {
  grok {
    match => [
    "message", "%{IP:client}",
    "message", "%{WINUSER:username}"
    ]
  }
 }
}
output {
  elasticsearch { host => localhost }
  stdout { codec => json }
}

更新:看来问题不在于模式,而在于匹配的顺序。如果我将 WINUSER 匹配移到 IP 匹配之上,它会起作用,但 IP 匹配不会。不知道为什么两者不匹配。

【问题讨论】:

    标签: regex logstash-grok


    【解决方案1】:

    原来问题出在配置文件的过滤器部分。我不得不将 grok 匹配分成多行,如下所示。

    filter {
      if [type] == "eventlog" {
      grok {
        match => [ "message", "%{IPV4:client}" ]
      }
      grok {
        match => [ "message", "%{WINUSER:username}" ]
      }
     }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-19
      • 2017-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-09
      相关资源
      最近更新 更多