Splunk Search

How to create pairs of events based on non-unique id

jerrynandak
New Member

I have hundreds of thousands of events of this form.

id event_type
11 ack
11 req
11 ack
12 req
11 req
12 ack
11 ack
13 req
12 req
12 req
11 req
12 ack
13 ack
12 ack
13 req

How can I create req-ack pairs of these events so that I can find the time difference between req and ack?

Expected pairing:
11 req-ack, req-ack
12 req-ack, req-ack, req-ack
13 req-ack
   

Labels (3)
0 Karma

jerrynandak
New Member

Hi @gcusello 

values() only stores distinct values. So, your solution gives the following output which doesn't match my expected result.

11
ack
req
12
ack
req
13
ack
req
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jerrynandak,

add nomv to the end:

| makeresults | eval id=11,  event_type="ack" | fields id event_type
| append [ | makeresults | eval id=11,  event_type="req" | fields id event_type ]
| append [ | makeresults | eval id=11,  event_type="ack" | fields id event_type ]
| append [ | makeresults | eval id=12,  event_type="req" | fields id event_type ]
| append [ | makeresults | eval id=11,  event_type="req" | fields id event_type ]
| append [ | makeresults | eval id=12,  event_type="ack" | fields id event_type ]
| append [ | makeresults | eval id=11,  event_type="ack" | fields id event_type ]
| append [ | makeresults | eval id=13,  event_type="req" | fields id event_type ]
| append [ | makeresults | eval id=12,  event_type="req" | fields id event_type ]
| append [ | makeresults | eval id=12,  event_type="req" | fields id event_type ]
| append [ | makeresults | eval id=11,  event_type="req" | fields id event_type ]
| append [ | makeresults | eval id=12,  event_type="ack" | fields id event_type ]
| append [ | makeresults | eval id=13,  event_type="ack" | fields id event_type ]
| append [ | makeresults | eval id=12,  event_type="ack" | fields id event_type ]
| append [ | makeresults | eval id=12,  event_type="req" | fields id event_type ]
| stats values(event_type) AS event_type BY id
| nomv event_type

Ciao.

Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jerrynandak,

please try this:

<your_search>
| stats values(event_type) AS event_type BY id 

Ciao.

Giuseppe

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...