Splunk Search

Need help with this REGEX that uses AND and OR

echojacques
Builder

I have a nullQueue setup in my transforms.conf and this regex works perfectly to drop all "service=53" OR "dst=10.10.10.10" events from getting indexed:

REGEX=(service=53|dst=10.10.10.10)

Now, I need to modify it so that it continues to drop all service=53 events but for dst=10.10.10.10, it only drops service=80 OR service=5000 events and keeps the rest. In other words, I need the regex to match this:

  1. drop all (service=53) events
  2. drop events when (dst=10.10.10.10 AND service=80) OR drop when (dst=10.10.10.10 AND service=5000).

To do this, I tried this regex and it didn't work:

REGEX=((service=53|(?=dst=10.10.10.10)(?=service=80|service=5000)))

I'm new to regex and any help would be great. Thanks.

Tags (1)
0 Karma
1 Solution

Ayn
Legend

Assuming dst comes before service in the events:

service=53|dst=10.10.10.10.+?(service=80|service=5000)

View solution in original post

Ayn
Legend

Assuming dst comes before service in the events:

service=53|dst=10.10.10.10.+?(service=80|service=5000)

echojacques
Builder

It works, thank you!!

0 Karma

echojacques
Builder

Thanks and yes, dst comes before service. I'll test it this afternoon.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...