In example B you need to use the and operator, not or. Otherwise you'll drop all messages except those containing DEBUG, WARN, INFO and ERROR at the same time.
my goal is to drop all the messages without DEBUG, WARN, INFO and ERROR.
Yes, I know.
example message withour DEBUG, INGO, ERROR, WARN
For that example message your option B works:
$ cat test.config
input { stdin { } }
output { stdout { codec => rubydebug } }
filter {
if "DEBUG" not in [message] or "WARN" not in [message] or "INFO" not in [message] or "ERROR" not in [message] {
drop { }
}
}
$ echo '00: 01 00 03 03 00 00 00 08 -- -- -- -- -- -- -- -- | ........' | /opt/logstash/bin/logstash -f test.config
Settings: Default pipeline workers: 8
Pipeline main started
Pipeline main has been shutdown
stopping pipeline {:id=>"main"}
(Logstash isn't emitting any events, proving that the drop filter worked.)
However, for other kinds of messages you do need to follow the advice I gave earlier.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.