I have a problem with a grok pattern when I have to extract a value that sometimes could be “blank” or “R”.
Example message: (with value R)
11/03/2021 14:02:59 1350 PACKET 000001A13A5BF570 UDP Rcv 208.67.222.222 5e4c R Q [8081 DR NOERROR] A (9)googleads(1)g(11)doubleclick(3)net(0)
Example message: (blank field)
11/03/2021 14:15:11 134C PACKET 000001A137513D50 UDP Rcv 192.168.1.6 8bd2 Q [0001 D NOERROR] A (3)ssl(7)gstatic(3)com(0)
My grok pattern: (it is incomplete because I have this problem)
Never worked with grok pattern before, so I’m not pretty sure if it have full support to regular expressions, but I cut a little piece of your examples and changed your regex a little bit to make it work:
[a-z0-9]{1,}([R ]{1,})?Q
This regex will work in both scenarios:
5e4c R Q
8bd2 Q
I just don’t know how to fit my example in your grok pattern