logstash:grok 解析失败

logstash: grok parse failure

我有这个配置文件

input {
  stdin {}
   file {
    type => "txt"
    path => "C:\Users\Gck\Desktop\logsatash_practice\input.txt"
    start_position=>"beginning"
  }
}


filter {
    grok {
        match => [ "message", "%{DATE:timestamp} %{IP:client} %{WORD:method} %{WORD:text}"]
      }
    date {
        match => [ "timestamp", "MMM-dd-YYYY-HH:mm:ss" ]
        locale => "en"
    }
}

output {
    file {
        path => "C:\Users\Gck\Desktop\logsatash_practice\op\output3.txt"
    }
}

假设这是我的输入:

MAY-08-2015-08:00:00 55.3.244.1 GET 你好

MAY-13-2015-13:00:00 56.4.245.2 GET 世界

在 运行 之后,我收到一条消息:grokparse 失败。

这是输出:

{"message":"MAY-08-2015-08:00:00\t55.3.244.1\thello\r","@version":"1","@timestamp":"2015-05-11T12:51:05.268Z","type" :"txt","host":"user-PC","path":"C:\Users\Gck\Desktop\logsatash_practice\input.txt","tags":["_grokparsefailure"]}

{"message":"MAY-13-2015-13:00:00\t56.4.245.2\tworld\r","@version":"1","@timestamp":"2015-05-11T12:51:05.269Z","type" :"txt","host":"user-PC","path":"C:\Users\Gck\Desktop\logsatash_practice\input.txt","tags":["_grokparsefailure"]}

我做错了什么?

同样重要 - 是否有任何指南以清晰明了的方式总结了此过滤内容? elastic guides不够详细

DATE grok 模式定义如下:

DATE %{DATE_US}|%{DATE_EU}

DATE_US 和 DATE_EU 依次定义如下:

DATE_US %{MONTHNUM}[/-]%{MONTHDAY}[/-]%{YEAR}
DATE_EU %{MONTHDAY}[./-]%{MONTHNUM}[./-]%{YEAR}

我可以继续,但很明显这与您的日志消息示例的实际内容不符:

MAY-08-2015-08:00:00 55.3.244.1 GET hello

没有与此日期格式相匹配的常规 grok 模式,但很容易将自定义模式放在一起。另外请注意,日志消息中标记之间的分隔符不是空格而是制表符。我们可以使用 \s 来匹配任何空白字符。工作示例:

(?<timestamp>%{WORD}-%{MONTHDAY}-%{YEAR}-%{TIME})\s%{IP:client}\s%{WORD:method}\s%{WORD:text}

Not less important- is there any guide that sums up this filtering thing in a good clear way? elastic guides aren't detailed enough.

除了特定于 grok 的 %{PATTERN_NAME:variable} 符号外,这都是普通的正则表达式,其他地方有许多介绍性指南。