Splunk Enterprise Security

How to compare 2 lists from 2 different searches ?

utk123
Path Finder

I have 2 different searches to create 2 hosts list, and I want below from splunk search:
1. Find all hosts from 1st search from a csv.
2. Find few hosts from different 2nd search with a criteria.
3. Find any host which is in List1 but not in List2, and populate in 3rd list.

Example:
List1 from search1 - Host1, Host2, Host3, Host6, Host7
List2 from search2 - Host2, Host3, Host4, Host5
List3 should be - Host1, Host6, Host7

My current splunk search listed below is showing all non-duplicate host from List1 & List2, which is not what I want.
Currently from below search my List3 shows me - Host1, Host4, Host5, Host6, Host7

| inputlookup hostlist.csv | rename host as hostname
| append [| search index=aaa AND bbb | rename name as hostname]
| stats count by hostname | search count=1 | table hostname

Thanks in advance.

0 Karma
1 Solution

renjith_nair
Legend

@utk123,

Test this with your data

| inputlookup hostlist.csv | rename host as hostname|eval source="one"
| append [| search index=aaa AND bbb | rename name as hostname|eval source="two"]
| stats values(source) as source,count by hostname | where count == 1 AND source="one"
---
What goes around comes around. If it helps, hit it with Karma 🙂

View solution in original post

renjith_nair
Legend

@utk123,

Test this with your data

| inputlookup hostlist.csv | rename host as hostname|eval source="one"
| append [| search index=aaa AND bbb | rename name as hostname|eval source="two"]
| stats values(source) as source,count by hostname | where count == 1 AND source="one"
---
What goes around comes around. If it helps, hit it with Karma 🙂

utk123
Path Finder

Thanks, above solution works.

0 Karma
Get Updates on the Splunk Community!

2024 Splunk Career Impact Survey | Earn a $20 gift card for participating!

Hear ye, hear ye! The time has come again for Splunk's annual Career Impact Survey!  We need your help by ...

Optimize Cloud Monitoring

  TECH TALKS Optimize Cloud Monitoring Tuesday, August 13, 2024  |  11:00AM–12:00PM PST   Register to ...

What's New in Splunk Cloud Platform 9.2.2403?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.2.2403! Analysts can ...