Splunk Search

Regex for nullQueue, conditional regex. Can someone figure it out?

adamsmith47
Communicator

Hello all,

I'm not sure this is doable with nullQueue in transforms to filter out events of this form, hopefully someone can crack it. For simplicity I will be using mock place holders instead of my actual events and regex.

So, my events may include two unique strings of text, which I'm capable of matching with {MyRegexA} and {MyRegexB}. There are only 3 possible event types which will be read:

1) "blah blah blah" {MyRegexA} "blah blah blah" {MyRegexB} "blah blah blah"
2) "blah blah blah blah blah blah blah blah blah" {MyRegexB} "blah blah blah"
3) "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah"

Sorry for the crudeness of examples, but the real events are quite large (hundreds of lines), and {MyRegexA} {MyRegexB} are also quite long.

I'm looking for a nullQueue regex which will discard ONLY event type #2, namely, where there is a match for {MyRegexB} but no match for {MyRegexA} prior in the event.

I was thinking a negative lookbehind of the form

(?<!{MyRegexA}){MyRegexB}

would do it, but that actually matches both #1 and #2. At least on my test site, www.regexr.com

Any advice?

0 Karma

paulstout
Path Finder

Would it be possible to assign a different sourcetype to events matching MyRegexA and MyRegexB? Example:

Let:

SourcetypeA = the incoming sourcetype
SourcetypeB = the new sourcetype that we do not want to discard

props.conf

[sourcetypeA]
TRANSFORMS-checkAB=checkAB, discardB

transforms.conf

[checkAB]
REGEX = YOUR_A_AND_B_REGEX
DEST_KEY = MetaData:Sourcetype
FORMAT = SourcetypeB

[discardB]
REGEX = YOUR_B_REGEX
DEST_KEY = queue
FORMAT=nullQueue

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Maximizing the Value of Splunk ES 8.x

Splunk Enterprise Security (ES) continues to be a leader in the Gartner Magic Quadrant, reflecting its pivotal ...