Splunk Search

Earliest particular event after another event

Samslara
Explorer

I have a problem with how to write a splunk query for my use. I'm trying to fetch values from an event where that event is the earliest one after another event. For example, given the sample data below, I'm trying to find the earliest activity=middle after an activity=start. Since there's two activity=middle I want the earliest and then fetch out the payload, which is in this case 1. How should I approach this?

data:

2011-01-01T12:00:00.000-0800 activity=start Correlation-ID=100001
2011-01-01T12:00:01.000-0800 activity=middle payload=1 Correlation-ID=100001
2011-01-01T12:00:02.000-0800 activity=middle payload=2 Correlation-ID=100001
Tags (2)
0 Karma

kristian_kolb
Ultra Champion

Well, if the log is no more complicated than your example, you could try with;

source=<your source> | reverse | dedup activity, Correlation_ID | stats values(payload) by Correlation_ID

Note that the underscores are intentional from me. Splunk likes it better that way. 🙂

hope this helps,

Kristian

Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

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