Splunk Search

How to exclude result from query?

karthi2809
Builder

Hi Guys,

In my scenario i need show error details for correlation id .There are field called tracePoint="EXCEPTION" and message field with PRD(ERROR):

In some cases we have exception first after that the transaction got success.So at that time i want to ignore the transaction in my query.But its not ignoring the success correlationId in my result

 

index="mulesoft" applicationName="s-concur-api" environment=PRD (tracePoint="EXCEPTION" AND message!="*(SUCCESS)*")|transaction correlationId | rename timestamp as Timestamp correlationId as CorrelationId tracePoint as TracePoint content.ErrorType as Error content.errorType
as errorType  content.errorMsg as ErrorMsg content.ErrorMsg as errorMsg
| eval ErrorType=if(isnull(Error),"Unknown",Error)
| dedup CorrelationId |eval errorType=coalesce(Error,errorType)|eval Errormsg=coalesce(ErrorMsg,errorMsg)
|table CorrelationId,Timestamp, applicationName, locationInfo.fileName, locationInfo.lineInFile, errorType, message,Errormsg
 | sort -Timestamp

 

 

Labels (1)
0 Karma
1 Solution

scelikok
SplunkTrust
SplunkTrust

You are right, I missed to filter again for exceptions. Please try below, you should see only correlationId exceptions that have no SUCCESS.

index="mulesoft" applicationName="s-concur-api" environment=PRD 
| eventstats values(tracePoint) as TracePoints values(message) as Messages by correlationId 
| search TracePoints="EXCEPTION" Messages!="*(SUCCESS)*" 
| fields - TracePoints - Messages
| search tracePoint="EXCEPTION"  
| transaction correlationId 
| rename timestamp as Timestamp correlationId as CorrelationId tracePoint as TracePoint content.ErrorType as Error content.errorType
    as errorType content.errorMsg as ErrorMsg content.ErrorMsg as errorMsg 
| eval ErrorType=if(isnull(Error),"Unknown",Error) 
| dedup CorrelationId 
| eval errorType=coalesce(Error,errorType) 
| eval Errormsg=coalesce(ErrorMsg,errorMsg) 
| table CorrelationId,Timestamp, applicationName, locationInfo.fileName, locationInfo.lineInFile, errorType, message,Errormsg 
| sort -Timestamp

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.

View solution in original post

scelikok
SplunkTrust
SplunkTrust

You are right, I missed to filter again for exceptions. Please try below, you should see only correlationId exceptions that have no SUCCESS.

index="mulesoft" applicationName="s-concur-api" environment=PRD 
| eventstats values(tracePoint) as TracePoints values(message) as Messages by correlationId 
| search TracePoints="EXCEPTION" Messages!="*(SUCCESS)*" 
| fields - TracePoints - Messages
| search tracePoint="EXCEPTION"  
| transaction correlationId 
| rename timestamp as Timestamp correlationId as CorrelationId tracePoint as TracePoint content.ErrorType as Error content.errorType
    as errorType content.errorMsg as ErrorMsg content.ErrorMsg as errorMsg 
| eval ErrorType=if(isnull(Error),"Unknown",Error) 
| dedup CorrelationId 
| eval errorType=coalesce(Error,errorType) 
| eval Errormsg=coalesce(ErrorMsg,errorMsg) 
| table CorrelationId,Timestamp, applicationName, locationInfo.fileName, locationInfo.lineInFile, errorType, message,Errormsg 
| sort -Timestamp

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.

scelikok
SplunkTrust
SplunkTrust

Hi @karthi2809,

Can you please try below with eventstats?

index="mulesoft" applicationName="s-concur-api" environment=PRD 
| eventstats values(tracePoint) as TracePoints values(message) as Messages by correlationId 
| search TracePoints="EXCEPTION" Messages!="*(SUCCESS)*" 
| fields - TracePoints - Messages
| transaction correlationId 
| rename timestamp as Timestamp correlationId as CorrelationId tracePoint as TracePoint content.ErrorType as Error content.errorType
    as errorType content.errorMsg as ErrorMsg content.ErrorMsg as errorMsg 
| eval ErrorType=if(isnull(Error),"Unknown",Error) 
| dedup CorrelationId 
| eval errorType=coalesce(Error,errorType) 
| eval Errormsg=coalesce(ErrorMsg,errorMsg) 
| table CorrelationId,Timestamp, applicationName, locationInfo.fileName, locationInfo.lineInFile, errorType, message,Errormsg 
| sort -Timestamp

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.

karthi2809
Builder

@scelikok  Yes its working But its showing all the timestamp and all the messages. Just i want to show error message not all transaction messages for the correlationId

0 Karma

bowesmana
SplunkTrust
SplunkTrust

It looks like you are excluding all the message=SUCCESS events, so you will never see them in the transaction data. If you want to exclude them, you will need to remove that message!="*(SUCCESS)*" constraint.

Then your transaction will have the SUCCESS event included, so at that point, you can then filter out those events that have both succeeded then failed.

However, you will need to take care of ordering - you know your data, but can the SUCCESS come AFTER the fail?

 

0 Karma
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!

Mastering Threat Intelligence in ES 8.5, Splunk AI Assistant v2, and More from Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

Break the Build: Inside the KubeDoom Lounge at .conf26

    You step up to the machine. The pixelated corridors of a certain 1993 FPS load in front of you, EMP Pulse ...

Splunk Auto Ingestion Parallel Pipeline Scaling

Why this feature matters Many Splunk environments experience ingestion pressure long before the host is fully ...