I'm getting farther and farther in the weeds with building out custom grok stuff. And before I make it too far I would like to know what the best practice for handling grok patterns is.
Is it best to make one giant grok?
grok {
match => { "message" => "%{GTINTLT:weirdnum}\s%{EPOCH:epoch}\s%{USER:device}\s%{LOGTYPE:logtype}\s%{ACTION:action}\s%{SRCIP}%{IP:scrip}\s%{DSTIP}%{IP:dstip}\s%{MACADDR}%{MAC: macaddr}\s%{PROTO}%{WORD:protocol}\s%{SPORT}%{INT:sport}\s%{DPORT}%{INT:dport}%{GREEDYDATA:message}" }
}
Is it better to break them out into grok chunks? (hehe grok chunks)
grok {
match => { "message" => "%{GTINTLT:weirdnum}\s%{GREEDYDATA:message}" }
overwrite => ["message"]
}
grok {
match => { "message" => "%{EPOCH:epoch}\s%{USER:device}\s%{GREEDYDATA:message}" }
overwrite => ["message"]
}
grok {
match => { "message" => "%{LOGTYPE:logtype}\s%{ACTION:action}\s%{GREEDYDATA:message}" }
overwrite => ["message"]
}
grok {
match => { "message" => "%{SRCIP}%{IP:scrip}\s%{DSTIP}%{IP:dstip}\s%{GREEDYDATA:message}" }
overwrite => ["message"]
}
grok {
match => { "message" => "%{MACADDR}%{MAC:macaddr}\s%{PROTO}%{WORD:protocol}\s%{GREEDYDATA:message}" }
overwrite => ["message"]
}
grok {
match => { "message" => "%{SPORT}%{INT:sport}\s%{DPORT}%{INT:dport}%{GREEDYDATA:message}" }
overwrite => ["message"]
}
Or maybe to use multiple matches in a single grok?
grok {
match => { "message" => "%{GTINTLT:weirdnum}\s%{GREEDYDATA:message}" }
overwrite => ["message"]
match => { "message" => "%{EPOCH:epoch}\s%{USER:device}\s%{GREEDYDATA:message}" }
overwrite => ["message"]
match => { "message" => "%{LOGTYPE:logtype}\s%{ACTION:action}\s%{GREEDYDATA:message}" }
overwrite => ["message"]
match => { "message" => "%{SRCIP}%{IP:scrip}\s%{DSTIP}%{IP:dstip}\s%{GREEDYDATA:message}" }
overwrite => ["message"]
match => { "message" => "%{MACADDR}%{MAC:macaddr}\s%{PROTO}%{WORD:protocol}\s%{GREEDYDATA:message}" }
overwrite => ["message"]
match => { "message" => "%{SPORT}%{INT:sport}\s%{DPORT}%{INT:dport}%{GREEDYDATA:message}" }
overwrite => ["message"]
}
Please note, I have not tested this one. So I have no clue if this one would work.
I'm old school, so I try to avoid going over 80 characters in length. But I also know that it may become needlessly complicated if I follow that.
So I am kind of looking for what the community actually does.