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
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...