Splunk Search

Search for data in different indexes and only return data is ip filed is same in both

jrprez1804
Path Finder

index=notable |rename src as ip | stats count by ip
| JOIN type=inner ip [search index="abcd" "tags.Dev:"cluster1 OR index="abcd" "tags.Dev:"=cluster2
| stats count by ip]

if ip is in notable index and cluster1 return ip AND if ip in notable index and cluster2 return ip

Tags (2)
0 Karma
1 Solution

to4kawa
Ultra Champion
index=notable OR (index="abcd" ("tags.Dev:"cluster1 OR "tags.Dev:"=cluster2))
| eval ip=coalesce(src,ip) 
| stats count dc(index) as flag by ip 
| where flag > 1

Hi, @jrprez1804
This query searches two indexes and tallies by each ip.
That time, it is checked the indexes where the ip belongs.
and Excludes ips that belongs one index.

How about this?

View solution in original post

0 Karma

to4kawa
Ultra Champion
index=notable OR (index="abcd" ("tags.Dev:"cluster1 OR "tags.Dev:"=cluster2))
| eval ip=coalesce(src,ip) 
| stats count dc(index) as flag by ip 
| where flag > 1

Hi, @jrprez1804
This query searches two indexes and tallies by each ip.
That time, it is checked the indexes where the ip belongs.
and Excludes ips that belongs one index.

How about this?

0 Karma

adonio
Ultra Champion

hello there,

first, you can always do something like that: index=notable | stats count by src as ip_count | rename src as ip which will perform much better.
but now for your join question.
there are couple (or more) ways to achieve, but the overall idea is to first bring all the results to one place with a wider search, and then slice and dice as you wish. for example:

(index=notable src=*) OR (index="abcd" "tags.Dev:"cluster1 OR index="abcd" "tags.Dev:"=cluster2)
| eval normalized_ip = coalesce(ip,src)
| stats dc(index) as unique_indexes by normalized_ip
| where unique_indexes > 1

play around with the data after you capture all of it, and suite yourself with the approach you like. there are many ways to go about this one...

hope it helps

0 Karma

to4kawa
Ultra Champion

If I was thinking about the explanation, I was late.
The way is the same. 🙂

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...