Splunk Search

Exclude results where two or more fields match

iomega311
Explorer

I am trying to understand how to remove results where "field_a" and "field_a" each contain a certain value together in the same log... but not all results containing "field_a" or all results containing "field_b"... or any other fields.

Here are some example of logs:

field_a=5 field_b=3

field_a=5 field_b=2

field_a=2 field_b=3

I want to exclude only logs where field_a is equal to "5" AND field_b is equal to "3" ... but keep all other results. So, in the log examples above, I would only want to exclude the first log because that is the only example where BOTH fields contain a specific value... I would want my query to return the last two logs.

0 Karma
1 Solution

sbuntin_splunk
Splunk Employee
Splunk Employee

NOT ( field_a=5 AND field_b=3 )

add this within your base search or in subsequent search command

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Perhaps this will help.

index=foo NOT (field_a=5 AND field_b=3)
---
If this reply helps you, Karma would be appreciated.

sbuntin_splunk
Splunk Employee
Splunk Employee

NOT ( field_a=5 AND field_b=3 )

add this within your base search or in subsequent search command

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!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...