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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

SOK it to Me: Top 3 Benefits of Using Splunk Operator on Kubernetes that’ll Make ...

    Thursday, July 9, 2026  |  11:00AM–12:00PM PDT Duration: 1 hour (includes Q&A) Managing can feel like a ...

Upgrade Prep for 10.4, Network Observability Deep Dives, and More from Splunk Lantern

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

Splunk Developer Day announcements: AI agents, MCP tools, Forecasting, and Custom ...

Splunk Developer Day was packed with product and platform updates for developers building in the AI ...