Splunk Search

How can I combine two queries based on chronological order?

dukie
New Member

I have two searches and I am trying to join start and stop post based on event name. Problem is event name could be the same so ”stats first(*) as * by Event_same_name” is not working for me.

I have sorted the table based on time, so I know the start and stop is in chronicle and correct order

Table:

Event_same_name     Start_epoch     Stop_epoch
Event               time_A
Event                               time_B
Event               time_C  
Event                               time_D
Event               time_E  
Event                               time_F

Output:

Event_same_name     Start_epoch     Stop_epoch
Event               time_A          time_B                                 
Event               time_C          time_D                
Event               time_E          time_F
Tags (2)
0 Karma
1 Solution

renjith_nair
Legend

@dukie,

Try

"your search to sort events" |eval rowno=1|accum rowno
|streamstats current=f window=1 last(_time) as Start_epoch|where rowno%2==0|rename _time as Stop_epoch|fields - rowno

Start event which does not have an end event is neglected here.

---
What goes around comes around. If it helps, hit it with Karma 🙂

View solution in original post

0 Karma

renjith_nair
Legend

@dukie,

Try

"your search to sort events" |eval rowno=1|accum rowno
|streamstats current=f window=1 last(_time) as Start_epoch|where rowno%2==0|rename _time as Stop_epoch|fields - rowno

Start event which does not have an end event is neglected here.

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma
Get Updates on the Splunk Community!

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to Officially Supported Splunk ...