我有来自一个日志源的事件,它可以有几种已知的格式。作为一个例子
10:45 Today is Monday
11:13 The weather is nice
12:00 The weather is cloudy
我可以{/ 1}}通过
每个人match
The weather is %{WORD:weather}
Today is %{WORD:weekday}
我对logstash filter
的格式感到不舒服。为了解释这些可能性中的每一种,我应该构建像
if message =~ "The weather is"
{
grok {
"match" => "The weather is %{WORD:weather}"
}
}
if message =~ "Today is"
{
grok {
"match" => "Today is %{WORD:weekday}"
}
}
还是有更紧凑的东西? (例如,具有相关映射的事件的可能模式列表)
答案 0 :(得分:0)
我找到了一个解决方案:枚举模式:
filter {
grok {
match => { "message" => [ "hello %{WORD:who}", "the weather is %{WORD:weather}" ] }
}
}