Splunk Search

How to stats by merging multiple events

humantorch
New Member

I have events in same index and source-type as follows:

9/12/19 11:28:46.398 AM [WARNING/ForkPoolWorker-13] project="xyz",begin="stage1",job_id=1
9/12/19 11:30:46.398 AM [WARNING/ForkPoolWorker-13] project="xyz",begin="stage1",job_id=2
9/12/19 11:38:46.398 AM[WARNING/ForkPoolWorker-13] project="xyz",end="stage1",job_id=1
9/12/19 11:35:46.398 AM[WARNING/ForkPoolWorker-13] project="xyz",end="stage1",job_id=2
9/12/19 11:35:48.398 AM[WARNING/ForkPoolWorker-13] project="xyz",begin="stage2",job_id=2
9/12/19 11:38:48.398 AM[WARNING/ForkPoolWorker-13] project="xyz",begin="stage2",job_id=1
9/12/19 11:45:48.398 AM[WARNING/ForkPoolWorker-13] project="xyz",end="stage2",job_id=2
9/12/19 11:45:50.398 AM[WARNING/ForkPoolWorker-13] project="xyz",result="SUCCESS",job_id=2
9/12/19 11:48:46.398 AM[WARNING/ForkPoolWorker-13] project="xyz",end="stage2",job_id=1
9/12/19 11:48:47.398 AM[WARNING/ForkPoolWorker-13] project="xyz",result="SUCCESS",job_id=1

I want to create a table for each project that lists all job_id and duration of each stages followed by whether that job_id was SUCCESS or FAIL

Like this:

Project XYZ Report:
job_id stage1(min) stage2(min) result


1 10 8 SUCCESS
2 5 10 SUCCESS

I tried join and append but they are really slow. What is the best way to achieve this?

Tags (2)
0 Karma

renjith_nair
Legend

@humantorch ,

Try this and test against your data

"your base search" "other filters"
|eventstats values(result) as result by job_id,project
|eval stage=coalesce(begin,end)
|stats min(_time) as start,max(_time) as end,first(result) as result by job_id,stage,project
|eval diff=round((end-start)/60,2)
|eval {stage}=diff|fields - stage,start,end,diff
|stats values(*) as * by project,job_id
---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma
Get Updates on the Splunk Community!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...