Splunk Search

simple questions about a search

nebel
Communicator

hi there,

with the search...

`all_forwarders` | fields sourceHost 

...I will get all forwarder host names.
On the other hand I have a csv file which includes all servers. Now I want to create a diff between the csv file and the 'all forwarders' search.

At the moment I am using the following search to built a diff

inputlookup all_servers | search NOT [search `all_forwarders` | fields sourceHost]

The search is very not very efficient I think. Sometimes it gets totaly wrong results, sometimes it works fine...There a more than 8000 servers in the list...

Could you please help me to find more efficient search string?

Thank you very much in advance!

Regards

Tags (1)
0 Karma
1 Solution

lguinn2
Legend

Well, one problem is that your subsearch will return only 100 events; this is probably why you are not getting consistent results. I would do it this way

| inputlookup all_servers 
| fields sourceHost
| eval match_found=0
| join type=outer sourceHost
  [ search `all_forwarders`
    | eval match_found=1
    | fields sourceHost match_found 
    | format maxresults = 10000 ]
| where match_found = 0

I am not sure that this is more efficient, but it should at least be right.

View solution in original post

0 Karma

lguinn2
Legend

Well, one problem is that your subsearch will return only 100 events; this is probably why you are not getting consistent results. I would do it this way

| inputlookup all_servers 
| fields sourceHost
| eval match_found=0
| join type=outer sourceHost
  [ search `all_forwarders`
    | eval match_found=1
    | fields sourceHost match_found 
    | format maxresults = 10000 ]
| where match_found = 0

I am not sure that this is more efficient, but it should at least be right.

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 ...