Splunk Search

Removing rows from table based on more than one field

kxmorrr
Engager

Hi,

I am trying to filter out fields from a table based on its content, example:

LP. NAME SURNAME STREET CITY
1. Bob Smith mainst florida
2. Greg Obama secondaryst miami

I want to remove second row from table based on fact that it have "Greg" AND "Miami" in name and city fields.

So far I tried:
|search Name NOT "Greg" AND City NOT "Miami"
but it didnt work for me. Any ideas?

Labels (2)
0 Karma
1 Solution

PickleRick
SplunkTrust
SplunkTrust

Depends on what you want to get. But your

|search Name NOT "Greg" AND City NOT "Miami"

means something different that you want.

If you don't compare field names to a value (might be a wildcard), splunk treats it as an ordinary text to search. Also, if you don't specify other operations, you have implied AND, so your search is equal to

|search "Name" AND NOT "Greg" AND "City" AND NOT "Miami"

It's definitely not what you want.

You want (depending on the desired outcome)

| search Name!="Greg" AND City!="Miami"

 or maybe

| search Name!="Greg" OR City!="Miami"

Depending on whether you want to filter out one or both possibilities at the same time.

And remember that with splunk A!=B is not the same as NOT A=B

View solution in original post

PickleRick
SplunkTrust
SplunkTrust

Depends on what you want to get. But your

|search Name NOT "Greg" AND City NOT "Miami"

means something different that you want.

If you don't compare field names to a value (might be a wildcard), splunk treats it as an ordinary text to search. Also, if you don't specify other operations, you have implied AND, so your search is equal to

|search "Name" AND NOT "Greg" AND "City" AND NOT "Miami"

It's definitely not what you want.

You want (depending on the desired outcome)

| search Name!="Greg" AND City!="Miami"

 or maybe

| search Name!="Greg" OR City!="Miami"

Depending on whether you want to filter out one or both possibilities at the same time.

And remember that with splunk A!=B is not the same as NOT A=B

kxmorrr
Engager

I want to remove field if and only if both conditions are satisfied, this is when name is Greg and city is Miami, but keep the row if none or only one is satisfied, 

| search Name!="Greg" AND City!="Miami"

Removes all Gregs from the table, but I only want those living in Miami gone. 

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Are you sure your field names are properly-cased? In splunk search values are case-insensitive but field names are case-sensitive.

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...