Splunk Search

correlation data from same index different soucetype

Symon
Explorer

I have the index=fortigate and there are two sourcetypes ("fgt_event" and "fgt_traffic").

index=fortigate sourcetype=fgt_event |stats count by user, assignip

userassignip
john192.168.1.1
paul192.168.1.2

 

index=fortigate soucetype=fgt_traffic | stats count by src srcport dest destport

srcsrcportdestdestport
192.168.1.1123410.0.0.122
192.168.1.2432110.0.0.222


I want to correlate the result like_

usersrc (or) assignipsrcportdestdestport
john192.168.1.1123410.0.0.122
paul192.168.1.2432110.0.0.222


I have learned SPL query like join,  mvappend, coalesce, subsearch ,etc. I tried a lot by combining the SPL functions to output. It doesn't still working. Please help me. Thanks.

Labels (3)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Symon ,

don't use join because it's a very slow search, use stats in this way:

index=fortigate sourcetype IN (fgt_event, fgt_traffic )
| eval src=coalesce(src,assignip)
| stats 
   values(srcport) AS srcport 
   values(dest) AS dest
   values(destport) AS destport
   BY user src

If you want only the events present in both the sourcetypes, you have to add an additional condition:

index=fortigate sourcetype IN (fgt_event, fgt_traffic )
| eval src=coalesce(src,assignip)
| stats 
   values(srcport) AS srcport 
   values(dest) AS dest
   values(destport) AS destport
   dc(sourcetype) AS sourcetype_count
   BY user src
| where sourcetype_count=2
| fields - sourcetype_count

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!

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, ...