Splunk Search

How to compare fields from two different event types

corwinz6
Explorer

Hello,

I am trying to come up with a search to compare the IP address values from two different log types contained in the same sourcetype. i.e. sourcetype=firewall (type=traffic AND status!=deny) Grab src and compare to src in (type=emailfilter AND blacklist)

I would then chart values that aren't denied in traffic but are blacklisted in a table showing the top 10.

How/is it possible to compare the src field in the traffic log to the src field in the email log if the above conditions are true?

Thanks

Tags (1)
0 Karma
1 Solution

Johnvey
Contributor

It sounds like you're trying to do an intersection of the following 2 searches:

(1)  sourcetype=firewall (type=traffic AND status!=deny)
(2)  sourcetype=firewall (type=emailfilter AND blacklist)

If that's true, then you can use stats to identify a field value for src that appears in both searches:

sourcetype=firewall (type=traffic AND status!=deny) OR (type=emailfilter AND blacklist) | stats count dc(type) as type_count by src | where type_count > 1 | sort count desc | head 10

This search assumes that the two searches actually produce mutually exclusive sets.

View solution in original post

Johnvey
Contributor

It sounds like you're trying to do an intersection of the following 2 searches:

(1)  sourcetype=firewall (type=traffic AND status!=deny)
(2)  sourcetype=firewall (type=emailfilter AND blacklist)

If that's true, then you can use stats to identify a field value for src that appears in both searches:

sourcetype=firewall (type=traffic AND status!=deny) OR (type=emailfilter AND blacklist) | stats count dc(type) as type_count by src | where type_count > 1 | sort count desc | head 10

This search assumes that the two searches actually produce mutually exclusive sets.

corwinz6
Explorer

Thanks, that looks to be working great. What prevents it from incrementing type_count when more than one event gets generated for (type=traffic AND status!=deny)with the same src value but no (type=emailfilter AND blacklist)?

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...