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!

Announcing Scheduled Export GA for Dashboard Studio

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

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...