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.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...