Splunk Search

How to use "NOT" condition in regular expression?

Madhan45
Path Finder

for example i have the string "update event from remote cache". i need to use NOT condition for this to capture ab events other than that.

Tags (1)
0 Karma

bmacias84
Champion

You might want to look at rex Non-capturing which may do what you want with some rex trickery, but with out some samples its tough to tell. http://www.regular-expressions.info/refcapture.html

0 Karma

woodcock
Esteemed Legend

Does this not work (you MUST use ALL-CAPS for NOT)?

NOT "event from remote cache"

jeffland
SplunkTrust
SplunkTrust

Maybe this answer on Stack Overflow is of interest to you.

But maybe you could just eval a field which flags events with your given string and filter based on that eval'd field, such as

your_search | eval check=if(match(field, "update\sevent\sfrom\sremote\scache","nope","ok") | where check="ok"

PS: this assumes that your string in question is in a field named "field".

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...