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

Get Updates on the Splunk Community!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...