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!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...