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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...