Hello everyone, I have the following question regarding the logstash filters.

I have logs that have fields that sometimes appear and sometimes do not, for example

"ip" = "", "mac" = "a1: a1: a1: a1: a1: a1", "bytes" = "100", "radio" = "a / g"
"ip" = "", "mac" = "a2: a2: a2: a2: a2: a2", "radio" = "B / g"

So in the grok I generate a pattern array something like that

grok {
match => {
"message" => ["" ip \ "= "% {IP: clientIP} \ "",
"" mac \ "= "% {mac} \ "",
"" bytes \ "= "% {NUMBER: bytes} \ "",
"" radio \ "= "% {DATA: radio} \ ""

I would like to ask you if it is necessary that all the elements of this array always appear in the message to work, and if the order of the elements of the array influences, or they capture the occurrence independent of the order in the array.

Have you considered using the kv filter instead of grok for this type of data? It should be able to handle aribrary combinations of fields more efficiently than grok.

Christian, thanks for your answer! The message that comes to me comes with quotes, do you know if this influences the kv filter?

If it causes problems you can always trim then using a mutate gsub filter before processing.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.