I've been working with Logstash for about 6 weeks. Trying to tag a message based on a field. When the grok match fails I get a _grokparsefailure tag. Here is the add_tag section and the entire filter below. When I negate the if [field] every message gets tagged even if when there is no match on the field.
What am I missing?
Should I be doing this in a Grok match?
For learning purposes can I add a tag to each match to better understand where matches are occurring?
Humbly,
if [ fac_msg ] {
mutate {
add_tag => [ "eocnetops" ]
}
}
##########################
filter {
if ([message] =~ "snmpHPTools"){
drop {}
}
else if ([message] =~ "User:HPOpenView"){
drop {}
}
else if ([message] =~ "NACUser"){
drop {}
}
else if ([message] =~ "permitted 172.26.122.78"){
drop {}
}
else if ([message] =~ "permitted 172.26.18.133"){
drop{}
}
else if ([message] =~ "%SSH-5-SSH2"){
drop{}
}
else if ([message] =~ "%SEC_LOGIN"){
drop{}
}
else if ([message] =~ "%AAA-5"){
drop{}
}
else if ([message] =~ "172.26.16.15 JACTDFPASC308 CSCOacs"){
drop{}
}
grok {
patterns_dir => ["/opt/logstash/patterns"]
break_on_match => true
match => [
"message", "%{SYSLOG5424PRI:syslog5424_pri}%{SYSLOGTIMESTAMP:sender_time} %{IPORHOST:syslog_host} %{NONNEGINT:sender_seq}: %{NONNEGINT:log_seq}: %{SYSLOGTIMESTAMP:source_time} %{TZ:time_zone}: \%%{DATA:fac_msg}: %{DATA:fac_msg1}, %{DATA:fac_msg2}$",
"message", "%{SYSLOG5424PRI:syslog5424_pri}%{SYSLOGTIMESTAMP:sender_time} %{IPORHOST:syslog_host} %{NONNEGINT:sender_seq}: %{NONNEGINT:log_seq}: %{SYSLOGTIMESTAMP:source_time} %{TZ:time_zone}: \%%{DATA:fac_msg}: %{DATA:fac_msg1}$",
"message", "%{SYSLOG5424PRI:syslog5424_pri}%{SYSLOGTIMESTAMP:sender_time} %{IPORHOST:syslog_host} %{NONNEGINT:sender_seq}: %{SINCEREBOOT:uptime}: \%%{DATA:fac_msg}: %{DATA:fac_msg1}$",
"message", "%{SYSLOG5424PRI:syslog5424_pri}%{SYSLOGTIMESTAMP:sender_time} %{IPORHOST:syslog_host} %{NONNEGINT:sender_seq}: %{SYSLOGTIMESTAMP:source_time} %{TZ:time_zone}: \%%{DATA:fac_msg}: %{DATA:fac_msg1}, %{DATA:fac_msg2}$",
"message", "%{SYSLOG5424PRI:syslog5424_pri}%{SYSLOGTIMESTAMP:sender_time} %{IPORHOST:syslog_host} %{NONNEGINT:sender_seq}: %{SYSLOGTIMESTAMP:source_time} (%{TZ:time_zone}*+): \%%{DATA:fac_msg}: %{DATA:fac_msg1}$",
"message", "%{SYSLOG5424PRI:syslog5424_pri}%{SYSLOGTIMESTAMP:sender_time} %{IPORHOST:syslog_host} %{NONNEGINT:sender_seq}: %{DATA:no_fac_msg1}$"
]
} # grok
if ![ fac_msg ] {
mutate {
add_tag => [ "eocnetops" ]
}
}
} # Filter