Splunk Search

How to filter out the list of hosts that are in the lookup but not in my search result?

pavanae
Builder

I have a query as follows which displays the list of hosts and their host details as follows

host    field_A   field_B    field_C

Now I have an Excel sheet which I'm trying to use as a lookup "hosts_list.csv"

Now I am trying to filter out the list of hosts that are in the lookup but not in my query result.

0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi pavanae,
try something like this

your_search
| eval host=upper(host)
| stats count by host
| append [ | inputlookup host_lookup.csv | eval host=upper(host), count=0 | fields host count ]
| stats sum(count) AS Total by host
| where Total=0

in this way you have the list of the hosts from your lookup that doesn't match in the main search.
Bye.
Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi pavanae,
try something like this

your_search
| eval host=upper(host)
| stats count by host
| append [ | inputlookup host_lookup.csv | eval host=upper(host), count=0 | fields host count ]
| stats sum(count) AS Total by host
| where Total=0

in this way you have the list of the hosts from your lookup that doesn't match in the main search.
Bye.
Giuseppe

cmerriman
Super Champion

the set command can help you, i think. your question didn't post the search query, make sure you use the 101 010 code button to format it properly.

|set diff [search 1] [|inputlookup hosts_list.csv]

http://docs.splunk.com/Documentation/Splunk/7.0.0/SearchReference/Set

MuS
Legend

and should this not work, just read this answer https://answers.splunk.com/answers/73268/search-for-hosts-in-a-lookup-but-not-in-splunk.html to get a different approach to make it work 😉

cheers, MuS

0 Karma

lloydknight
Builder

Hello, Can you share your search query?

0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...