使用 logstash 检查条件中的多个字符串
Checking for multiple strings in a conditional with logstash
我想找到在条件为真时添加字段标记的最简单方法。
if [target_index] == "myindex" and
("str1" in message
or "str2" in message
or "str3" in message){
mutate {
add_tag => ["mytag"]
}
}
我正在关注列出的文档 here。但是,当我重新启动 logstash 时,我得到 "LogStash::ConfigurationError
。也许有更好的方法来做到这一点?如果对此有任何帮助,我将不胜感激。
您需要用方括号括起对 [message] 的引用
filter {
if [target_index] == "myindex" and
("str1" in [message]
or "str2" in [message]
or "str3" in [message]){
mutate {
add_tag => ["mytag"]
}
}
就是说,我会在正则表达式中使用交替来写这个
if [target_index] == "myindex" and [message] =~ /str1|str2|str3/
我想找到在条件为真时添加字段标记的最简单方法。
if [target_index] == "myindex" and
("str1" in message
or "str2" in message
or "str3" in message){
mutate {
add_tag => ["mytag"]
}
}
我正在关注列出的文档 here。但是,当我重新启动 logstash 时,我得到 "LogStash::ConfigurationError
。也许有更好的方法来做到这一点?如果对此有任何帮助,我将不胜感激。
您需要用方括号括起对 [message] 的引用
filter {
if [target_index] == "myindex" and
("str1" in [message]
or "str2" in [message]
or "str3" in [message]){
mutate {
add_tag => ["mytag"]
}
}
就是说,我会在正则表达式中使用交替来写这个
if [target_index] == "myindex" and [message] =~ /str1|str2|str3/