Splunk Search

How to compare two fields from two different source types?

ahmed_aladwani
Engager

Hello everybody,

This is actually my first post here so forgive me if I missed up or posted in the wrong section. I'm trying to compare/corelate two fields values from different source types and same index. Please find two sample of event I'm trying to work on.

1) sample of the first source type

index=wineventlog

sourcetype=Script:ListeningPorts

host=computer1

dest=172.*.*.*

dest_port=50000

process_id=151111

 

2) sample of the second source type

index=wineventlog

sourcetype=WinHostMon

source=process

host=computer1

Path=***.exe

Process=**.exe

ProcessId=151111 

 

I'm trying to corelate process_id and ProcessId fields to get the process field and make a count table. Sample output:

process_id   |  dest_port  |  count   |  host               |  Path      |  process

151111               50000              1          Computer1      **.exe      **.exe

 

I tried this query but it didn't give me the right result

index=wineventlog sourcetype=Script:ListeningPorts dest="172.*.*.*" host="Computer1"
| table host process_id dest, dest_port
| rename process_id as ProcessId

| join type=inner host ProcessId
[search index=wineventlog sourcetype=WinHostMon
| table  ProcessId dest_port host Path process]

 

 

Labels (3)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

Try to avoid using join where possible, it has a number of limitations) - and in this case it's possible

(index=wineventlog sourcetype=Script:ListeningPorts dest="172.*.*.*" host="Computer1") OR (index=wineventlog sourcetype=WinHostMon host=Computer1)
| eval process_id=coalesce(process_id, ProcessId)
| stats values(dest) as dest values(Path) as Path values(process) as process by host process_id dest_port

The final stats statement will depend on what you want your output to be. This will probably be faster than a join and avoid its limitations

View solution in original post

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Try to avoid using join where possible, it has a number of limitations) - and in this case it's possible

(index=wineventlog sourcetype=Script:ListeningPorts dest="172.*.*.*" host="Computer1") OR (index=wineventlog sourcetype=WinHostMon host=Computer1)
| eval process_id=coalesce(process_id, ProcessId)
| stats values(dest) as dest values(Path) as Path values(process) as process by host process_id dest_port

The final stats statement will depend on what you want your output to be. This will probably be faster than a join and avoid its limitations

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...