Splunk Search

Help with search with multiple NOT IN subqueries

usarios
Engager
The goal is to take all eventIds with "operation failed" and exclude events with "Duplicate key" and "Event processed successfully":

index="idx" "Transaction failed" 
| table eventId
| dedup eventId
| search NOT [search index="idx" "Duplicate key"
             | table eventId ]
| search NOT [search index="idx" "Event processed successfully"
             | table eventId ] 

But for some reason the last NOT subquery doesn't exclude the events which processed successfully:
| search NOT [search index="idx" "Event processed successfully"
             | table eventId ] 
Labels (2)
Tags (2)
0 Karma
1 Solution

gcusello
Esteemed Legend

Hi @usarios,

let me inderstand there could be eventId with only one message or the same eventId could have different messages in different events?

if the second you could run something like this:

index="idx" ("Transaction failed" OR "Duplicate key" OR "Event processed successfully")
| eval message=case(searchmatch("Transaction failed"),"Transaction failed", searchmatch("Duplicate key"),"Duplicate key",searchmatch("Event processed successfully","Event processed successfully")
| stats dc(message) AS message_count values(message) AS message BY eventId
| where message_count=1 AND message="Transaction failed"
| table eventId

Ciao.

Giuseppe

View solution in original post

gcusello
Esteemed Legend

Hi @usarios,

let me inderstand there could be eventId with only one message or the same eventId could have different messages in different events?

if the second you could run something like this:

index="idx" ("Transaction failed" OR "Duplicate key" OR "Event processed successfully")
| eval message=case(searchmatch("Transaction failed"),"Transaction failed", searchmatch("Duplicate key"),"Duplicate key",searchmatch("Event processed successfully","Event processed successfully")
| stats dc(message) AS message_count values(message) AS message BY eventId
| where message_count=1 AND message="Transaction failed"
| table eventId

Ciao.

Giuseppe

usarios
Engager

Grazie, Giuseppe.

Yes, that works for me!

Ciao

0 Karma
Get Updates on the Splunk Community!

Build Scalable Security While Moving to Cloud - Guide From Clayton Homes

 Clayton Homes faced the increased challenge of strengthening their security posture as they went through ...

Mission Control | Explore the latest release of Splunk Mission Control (2.3)

We’re happy to announce the release of Mission Control 2.3 which includes several new and exciting features ...

Cloud Platform | Migrating your Splunk Cloud deployment to Python 3.7

Python 2.7, the last release of Python 2, reached End of Life back on January 1, 2020. As part of our larger ...