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
Get Updates on the Splunk Community!

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

 Prepare to elevate your security operations with the powerful upgrade to Splunk Enterprise Security 8.x! This ...

Get Early Access to AI Playbook Authoring: Apply for the Alpha Private Preview ...

Passionate about security automation? Apply now to our AI Playbook Authoring Alpha private preview ...

Reduce and Transform Your Firewall Data with Splunk Data Management

Managing high-volume firewall data has always been a challenge. Noisy events and verbose traffic logs often ...