Splunk Search

How to exclude a particular value from results when using the field extractor utility?

samuelrey
New Member

The field extractor wizard came up with the following:

(?=[^f]*(?:firewall:|f.*firewall:))^(?:[^"\n]*"){2}\s+(?P[^ ]+)(?:[^ \n]* ){4}(?P[^ ]+)(?:[^ \n]* ){3}(?P[^ ]+)\s+(?P[^ ]+)\s+\d+\s+(?P[^ ]+)[^"\n]*"(?P[^"]+)(?:[^ \n]* ){2}\((?P[^\)]+)

It sometimes interprets a field labeled msg (ex. msg="ip scan" is interpreted as user) as user for some reason (rare). When it does this, it always has a PolicyName="Internal Policy". It seems the easiest way to resolve the issue is to ignore any events having a PolicyName of 'Internal Policy'. How can I modify this regex/rex to accomplish that?

0 Karma
1 Solution

aljohnson_splun
Splunk Employee
Splunk Employee

When you're using the field extractor, sometimes you get weird values like you mentioned.

alt text

What you can do is click on the little X on the right side of the field that was incorrectly extracted.

alt text

After that, Splunk will try to recreate the the regular expression to exclude that value.


There is also a "require" option for selections in the field extractor. Adding more of these might help you filter out what you don't want.


Alternatively, as you mentioned, you can edit the regular expression. It becomes extra difficult since it is a machine generated regular expression, and often becomes easier to just write the regular expression (or multiple, simpler ones) instead of using the machine generated one. Either way, in that case, post some examples of the data (so someone could attempt to filter out the events with PolicyName or define the fields you want to try to extract)

View solution in original post

aljohnson_splun
Splunk Employee
Splunk Employee

When you're using the field extractor, sometimes you get weird values like you mentioned.

alt text

What you can do is click on the little X on the right side of the field that was incorrectly extracted.

alt text

After that, Splunk will try to recreate the the regular expression to exclude that value.


There is also a "require" option for selections in the field extractor. Adding more of these might help you filter out what you don't want.


Alternatively, as you mentioned, you can edit the regular expression. It becomes extra difficult since it is a machine generated regular expression, and often becomes easier to just write the regular expression (or multiple, simpler ones) instead of using the machine generated one. Either way, in that case, post some examples of the data (so someone could attempt to filter out the events with PolicyName or define the fields you want to try to extract)

samuelrey
New Member

Thanks. I was able how to use the method you described in the validate fields step correctly. I filtered on the unwanted value then excluded it.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Agent Mode Engaged! Enchaining Agentic Operations with Splunk AI Assistant 2.0

    Are you ready to transform how your team handles complex data requests? We invite you to our upcoming ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...