Splunk Search

search correction with NOT

aniketb
Path Finder

I have an alert setup. It is like

"ABC-* NOT ("ABC-1" OR "ABC-2")

"ABC-1", "ABC-2" being stuff I have taken care of.

My result is like:

ABC-
ABC-3
ABC-4
ABC-5

I want to remove that "ABC-".

The problem is, if I add it as NOT to the search, I see no results. Like in

"ABC-* NOT ("ABC-" OR "ABC-1" OR "ABC-2")

I get 0 results. How to do that correctly?

Tags (2)
0 Karma

lguinn2
Legend

Try this

"abc-* NOT ("abc-1" OR "abc-2" OR TERM("abc-"))

You can read more about TERM here

0 Karma

lguinn2
Legend

You can't use regex as the search, although you could run a search and then apply the regex command to it as @yannK did...

0 Karma

lukejadamec
Super Champion

Thanks for the new term... er tool.
Why not just use
regex _raw="ABC-\d"
as the search and then NOT whateverelse?

0 Karma

yannK
Splunk Employee
Splunk Employee

The ABC-* is very generic.

if you have a space after ABC-
"ABC-* NOT ("ABC-1" OR "ABC-2" OR "ABC- ")

otherwise, you can add a second regex filter after to keep only ABC-

"ABC-* NOT ("ABC-1" OR "ABC-2") | regex _raw="ABC-\d"

0 Karma

yannK
Splunk Employee
Splunk Employee

It works, the events with a non matching rex field "errorname" will have a null value for errorname, and should not appear in your stats by errorname.

0 Karma

aniketb
Path Finder

I do pass this to a regex because this is an error code. Your regex doesn't gel well with mine. My complete search string is

"ABC-" NOT ("ABC-1" OR "ABC-2") | rex "(?ABC-[0-9])" | stats count by ErrorName | sort-count

Also there's no space after "ABC-"

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...