Splunk Search

Compute some stats without discarding full results

waisbrot
Engager

I have logs of conversations, identified by a common field (a unique ID) and an end-marker. Some conversations get aborted without ending normally. I want a search that produces {_time, duration} pairs for every conversation that completed, and either {_time, running-sum} or final-sum for orphan transactions.

I could do this as two separate searches, one to get non-orphans

... | transaction convo_id endswith="end" unifyends=true keeporphans=false | table _time, duration

and one to get the orphans

... | transaction convo_id endswith="end" unifyends=true keeporphans=true | stats count(_txn_orphan) as orphan_count

But I'd rather not compute the transaction and the pipeline up to it twice in a row. Can I combine the last two parts of my search somehow?

Tags (1)
0 Karma
1 Solution

somesoni2
Revered Legend

Try something like this

your base search...| eventstats count as TotalEvents | transaction convo_id endswith="end" unifyends=true keeporphans=false | eventstats sum(eventcount) as TotalEventsInTransaction | eval orphan_count=TotalEvents-TotalEventsInTransaction | table _time, duration,orphan_count

View solution in original post

rsennett_splunk
Splunk Employee
Splunk Employee

I was thinking that what you might want to do is something like what Sondra Russell is talking about in this blog: http://blogs.splunk.com/2014/01/23/quick-n-dirty-funnels/

This is referring to a different contextual set of data, however all you need is a UniqueID and an end marker... there are ways you can "fill in" missing field so that you can basically see if they are there or not, which helps with "state" which is what you're checking in order to correlate the events. Can you show us some sample data?

With Splunk... the answer is always "YES!". It just might require more regex than you're prepared for!
0 Karma

somesoni2
Revered Legend

Try something like this

your base search...| eventstats count as TotalEvents | transaction convo_id endswith="end" unifyends=true keeporphans=false | eventstats sum(eventcount) as TotalEventsInTransaction | eval orphan_count=TotalEvents-TotalEventsInTransaction | table _time, duration,orphan_count
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 ...