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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...