Splunk Search

Find missing hosts after referencing a lookup file.

jason_hotchkiss
Communicator

Hello I have the following search which produces  statistics(746) in Splunk:

 

index=my_index sourcetype=my_st id=100 host!=10.* earliest=-1d@d
| stats values(repot) as repot dc(repot) as repost_count values(ip) as ip_address dc(ip) as ip_count by host
|table host ip_count ip_address repot_count repot

 

  
I am then using a lookup file to filter out unwanted hosts from the above search (which produces statitics(676) in Splunk.

 

| search
 [ |inputlookup my_host_list
   |table host ip_address ]
   |dedup host
   |table host ip_count ip_address repot_count repot

 


How would I determine the host names of the 70 missing hosts from the my_host_list lookup?

Labels (3)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

You're looking for hosts not in the lookup file so use the NOT keyword in the search.

| search NOT
 [ |inputlookup my_host_list
   |table host ip_address ]
   |dedup host
   |table host ip_count ip_address repot_count repot

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @jason_hotchkiss,

you could run something like this:

index=my_index sourcetype=my_st id=100 host!=10.* earliest=-1d@d
| stats 
   values(repot) as repot 
   dc(repot) as repost_count 
   values(ip) as ip_address 
   dc(ip) as ip_count 
   count
   BY host
| append [ |inputlookup my_host_list
   | eval count=0
   | fields host ip_address count ]
| stats 
   values(repot) as repot 
   dc(repot) as repost_count 
   values(ip) as ip_address 
   dc(ip) as ip_count 
   sum(count) As total
   BY host
| eval status=if(total=0,"missing","present"
| table host ip_count ip_address repot_count repot status

Ciao.

Giuseppe

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

You're looking for hosts not in the lookup file so use the NOT keyword in the search.

| search NOT
 [ |inputlookup my_host_list
   |table host ip_address ]
   |dedup host
   |table host ip_count ip_address repot_count repot

 

---
If this reply helps you, Karma would be appreciated.

jason_hotchkiss
Communicator

@richgalloway - thank you.  I think I have been staring at this screen too long....

Get Updates on the Splunk Community!

What’s New in Splunk Cloud Platform 9.1.2308?

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

Index This | Why do they call it hyper text?

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

State of Splunk Careers 2023: Career Resilience and the Continued Value of Splunk

For the past three years, Splunk has partnered with Enterprise Strategy Group to conduct a survey that gauges ...