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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...