Splunk Search

How to achieve sum of two fields excluding null fields?

monicateja
Explorer

Hi,

can any one help me how to get splunk query for below requirement.

index="abc"
| search "message"="Exit" | search "stepName"=NotifyFlowEnd | search stepName!=""
| search "message"="PAST_TIME_FRAME"
|  chart count by "message"

In message="Exit"  these 2 conditions need to include ----->     | search "stepName"=NotifyFlowEnd | search stepName!=""

 

Output is to get Sum of  "message"="Exit"  +  "PAST_TIME_FRAME" count

Labels (3)
0 Karma

monicateja
Explorer

Thanks for response. Query is working but only getting count values for message=Exit but not for PAST_TIME_FRAME

step.name= NotifyFlowEnd is extra filter for message=Exit and need to remove step.name=“”

0 Karma

yuanliu
SplunkTrust
SplunkTrust

In that case,

index="abc" (("message"="Exit" "stepName"=NotifyFlowEnd) OR (message="PAST_TIME_FRAME" stepName!=""))
| chart count by "message"

It is much better to explain the problem and data in text even when you illustrate code that you tried.  Also, if the code you tried did not get the desired result, describe the result and explain why it is not desired.  This way, others do not have to guess what you meant in code fragments that do not reflect the actual requirements.

0 Karma

yuanliu
SplunkTrust
SplunkTrust
index="abc" "message" IN ("Exit", "PAST_TIME_FRAME") "stepName"=NotifyFlowEnd
| chart count by "message"

This should do.  Note that search commands should be combined in the first command as much as possible.  Another thing to note is that if you have stepName=NotifyFlowEnd, stepName !="" would be unnecessary.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...