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!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...