Splunk Search

is it possible to get the sum of a multivalued field within a transaction without a unique id??

vijai_thomas
Engager

Hi,
I want to count the number or errors within two keywords say starttran and endtran.
My log data would be like

  • starttran
  • tran Id:1000
  • error*
  • abc done
  • error*
  • endtran

My query : sourcetype="abc" | eval haserror=if(searchmatch("error"),1,0) | transaction startswith=starttran endswith=endtran mvlist=haserror | table haserror TRANID

O/P

  • haserror / TRANID
  • 0
  • 0 / 1000
  • 1
  • 0
  • 1
  • 0

But i want it like

  • haserror / TRANID
  • 2 / 1000

I tried using sum(haserror) by TRANID but din't. Kindly help . Also here can't TRANID be used as unique ID ?

Thanks a lot

Tags (2)
0 Karma
1 Solution

lguinn2
Legend
sourcetype="abc" 
| eval haserror=if(searchmatch("error"),1,0) 
| transaction startswith=starttran endswith=endtran mvlist=haserror 
| eval ErrorCount = mvcount(mvfilter(haserror==1))
| table ErrorCount TRANID

should work

View solution in original post

lguinn2
Legend
sourcetype="abc" 
| eval haserror=if(searchmatch("error"),1,0) 
| transaction startswith=starttran endswith=endtran mvlist=haserror 
| eval ErrorCount = mvcount(mvfilter(haserror==1))
| table ErrorCount TRANID

should work

vijai_thomas
Engager

This worked .. Thanks a lot 🙂

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