Splunk Search

How to combine searches to generate stats of domains with "success" and "failure" columns?

tlmayes
Contributor

I am attempting to combine two searches against a custom app within custom props.conf but am going in circles. Both searches are the same, with the exception of: Search1 is reporting on a "yes" or success statement, Search2 is reporting on a "no" or failed statement. I am trying to generate stats of domains with a success column and a failure column. Is there a better way?

Search 1

eventtype=some_events APP1
| search (*) (*) NOT ("filter expression") 
| search "APP1 Version:" OR "MODULE: Report MESSAGE: Results:" OR "Response" system=*
| transaction system maxspan=24h 
| eval completed=if(searchmatch("Results:"),"yes","no")  
| search completed=yes
| rex field=system "[^.]*.(?.*)" 
| stats count by FQDN 
| sort -count
| rename count AS success
| dedup FQDN

Search 2

eventtype=some_events APP1
| search (*) (*) NOT ("filter expression") 
| search "APP1 Version:" OR "MODULE: Report MESSAGE: Results:" OR "Response" system=*
| transaction system maxspan=24h 
| eval completed=if(searchmatch("Results:"),"yes","no")  
| search completed!=yes
| rex field=system "[^.]*.(?.*)" 
| stats count by FQDN 
| sort -count
| rename count AS failed
| dedup FQDN

Desired output:

FQDN                Success                        Failed
domain1.com         ##                             ##
domain2.com         ##                             ##
0 Karma
1 Solution

cmerriman
Super Champion

try something like this

eventtype=some_events APP1
| search () () NOT ("filter expression") 
| search "APP1 Version:" OR "MODULE: Report MESSAGE: Results:" OR "Response" system=
| transaction system maxspan=24h 
| eval completed=if(searchmatch("Results:"),"yes","no") 
| rex field=system "[^.].(?.*)" 
| stats count(eval(match(completed,"yes"))) as success count(eval(match(completed,"no"))) as failed by FQDN

View solution in original post

0 Karma

cmerriman
Super Champion

try something like this

eventtype=some_events APP1
| search () () NOT ("filter expression") 
| search "APP1 Version:" OR "MODULE: Report MESSAGE: Results:" OR "Response" system=
| transaction system maxspan=24h 
| eval completed=if(searchmatch("Results:"),"yes","no") 
| rex field=system "[^.].(?.*)" 
| stats count(eval(match(completed,"yes"))) as success count(eval(match(completed,"no"))) as failed by FQDN
0 Karma

tlmayes
Contributor

Worked perfect. Greatly appreciated

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 ...