Splunk Search

How to combine two events based on common field?

dminev1
Explorer

Hi everyone,

I am using splunk for about two week at my work and I have task to build dashboard. I have splunk query that extracts data from 2 different events but in the same source. The events share common ID. I am trying to combine the events based on the ID and represent the data from both events in a dashboard. I tried with multisearch and by. None of them worked. Can anyone give me a hit on how to approach this problem? Here is the query and a screen shot from the result:

index=?????? sourcetype=???? host=????? source=????????? "Number of Clients" OR "Duration::  in " 
              | rex field=_raw "Number of Clients: (?<ClientCount>\d+)"
              | rex field=_raw "cid:(?<CID>\w+-\w+-\w+-\w+-\w+)" 
              | rex field=_raw "Duration::  in (?<Duration>\d+.\d+)"
              | eval Size = if(ClientCount == 0, "Not part of association", if(ClientCount <= 3, "Small", if(ClientCount <= 10 ,"Medium",if (ClientCount > 10, "Large", ClientCount))))
              | table Size Duration CID

alt text

Tags (3)
0 Karma
1 Solution

dminev1
Explorer

Got it working. Here is the solution

index=??? sourcetype=??? host=???? source=???? ("Number of Clients" OR "Duration::  in ")
              | rex field=_raw "Number of Clients: (?<ClientCount>\d+)"
              | rex field=_raw "cid:(?<CID>\w+-\w+-\w+-\w+-\w+)" 
              | rex field=_raw "Duration::  in (?<Duration>\d+.\d+)"
              | eval Size = if(ClientCount == 0, "Not part of association", if(ClientCount <= 3, "Small", if(ClientCount <= 10 ,"Medium",if (ClientCount > 10, "Large", ClientCount))))
              | stats values(Duration) as Duration values(Size) as Size by CID

View solution in original post

0 Karma

dminev1
Explorer

Got it working. Here is the solution

index=??? sourcetype=??? host=???? source=???? ("Number of Clients" OR "Duration::  in ")
              | rex field=_raw "Number of Clients: (?<ClientCount>\d+)"
              | rex field=_raw "cid:(?<CID>\w+-\w+-\w+-\w+-\w+)" 
              | rex field=_raw "Duration::  in (?<Duration>\d+.\d+)"
              | eval Size = if(ClientCount == 0, "Not part of association", if(ClientCount <= 3, "Small", if(ClientCount <= 10 ,"Medium",if (ClientCount > 10, "Large", ClientCount))))
              | stats values(Duration) as Duration values(Size) as Size by CID
0 Karma

adonio
Ultra Champion

very good,
if it works for you, kindly mark the answer as accepted, and upvote ant helpful comments if any so others will know this solution worked for you.

thanks and happy splunking!

0 Karma

adonio
Ultra Champion

try this:

index=?????? sourcetype=???? host=????? source=????????? "Number of Clients" OR "Duration:: in " 
| rex field=_raw "Number of Clients: (?\d+)" 
| rex field=_raw "cid:(?\w+-\w+-\w+-\w+-\w+)" 
| rex field=_raw "Duration:: in (?\d+.\d+)" 
| eval Size = if(ClientCount == 0, "Not part of association", if(ClientCount <= 3, "Small", if(ClientCount <= 10 ,"Medium",if (ClientCount > 10, "Large", ClientCount)))) 
| stats values(CID) as CID by  Duration SIze
0 Karma

dminev1
Explorer

Doesn't return any result. Thanks for the reply.

0 Karma

adonio
Ultra Champion

try Size i hade it with CAPITAL I there by accident

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!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...