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!

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!

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

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...