Splunk Search

How to search all field values except a particular one?

summitsplunk
Communicator

I have an app that can show source by country

Example:
Country=China

In SPL how would I format this if I wanted to Search like all possible values for Country except like USA?

Tags (1)
0 Karma
1 Solution

cmerriman
Super Champion

try Country!=*USA* if there is a wildcard, not that I can imagine a wildcard in the country.
otherwise, Country!="USA" or NOT Country="USA" should do the trick

it should be noted that when using !=, any event that does not include Country will also be excluded whereas when using NOT, events where Country doesn't exist will come back as well. So if Country is in 80% of your events and you only want to exclude "USA" but want to include events without Country, use NOT Country="USA". If you want to exclude both null country values as well as USA, use Country!="USA"

View solution in original post

cmerriman
Super Champion

try Country!=*USA* if there is a wildcard, not that I can imagine a wildcard in the country.
otherwise, Country!="USA" or NOT Country="USA" should do the trick

it should be noted that when using !=, any event that does not include Country will also be excluded whereas when using NOT, events where Country doesn't exist will come back as well. So if Country is in 80% of your events and you only want to exclude "USA" but want to include events without Country, use NOT Country="USA". If you want to exclude both null country values as well as USA, use Country!="USA"

Get Updates on the Splunk Community!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco + Splunk! We’ve ...