<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to subtract results from inner search and then from outer search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-results-from-inner-search-and-then-from-outer/m-p/472535#M132981</link>
    <description>&lt;P&gt;There are a few ways to potentially solve this, but realize that looking for something that doesn't exist is not a great situation.&lt;BR /&gt;
I think I would evaluate it with a &lt;CODE&gt;case&lt;/CODE&gt; statement, because later on, it allows you at add additional conditions if needed.&lt;BR /&gt;
I might go with something similar to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=servers
| eval ServerType=case(
     EventID = "XYZ","not_wanted_servers",
     1=1, "target_servers"
     )
| where ServerType="target_servers "
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We are evaluating (&lt;CODE&gt;eval&lt;/CODE&gt; command) your servers into Server types: ones not wanted and ones targeted.&lt;BR /&gt;
EventID="XYZ" is to be called not_wanted_servers, and everything else is to be called target_servers.&lt;BR /&gt;
Then we use the &lt;CODE&gt;where&lt;/CODE&gt;, so only look for the targeted ServerType, target_servers.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 04:06:56 GMT</pubDate>
    <dc:creator>efavreau</dc:creator>
    <dc:date>2020-09-30T04:06:56Z</dc:date>
    <item>
      <title>How to subtract results from inner search and then from outer search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-results-from-inner-search-and-then-from-outer/m-p/472534#M132980</link>
      <description>&lt;P&gt;Hi everybody,&lt;/P&gt;

&lt;P&gt;I need to find out all the servers on which the Windows EventID=XYZ is not logged.&lt;BR /&gt;
Therefore I run a search for all servers in my index (to have all the servers) and then I do an inner search where I only search for servers where at least one single time the EventID=XYZ was logged.&lt;BR /&gt;
When I now subtract this result from the "all servers" result only those should remain which didn't log the EventID=XYZ.&lt;/P&gt;

&lt;P&gt;But how is this done?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=servers
[search index=servers EventID=XYZ
    | stats values(host) as not_wanted_servers
    | fields not_wanted_servers]
| stats values(host) as target_servers
|where target_servers NOT in not_wanted_servers
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The last line doesn't work but should show what I want to do.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 15:27:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-results-from-inner-search-and-then-from-outer/m-p/472534#M132980</guid>
      <dc:creator>qman</dc:creator>
      <dc:date>2020-02-14T15:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract results from inner search and then from outer search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-results-from-inner-search-and-then-from-outer/m-p/472535#M132981</link>
      <description>&lt;P&gt;There are a few ways to potentially solve this, but realize that looking for something that doesn't exist is not a great situation.&lt;BR /&gt;
I think I would evaluate it with a &lt;CODE&gt;case&lt;/CODE&gt; statement, because later on, it allows you at add additional conditions if needed.&lt;BR /&gt;
I might go with something similar to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=servers
| eval ServerType=case(
     EventID = "XYZ","not_wanted_servers",
     1=1, "target_servers"
     )
| where ServerType="target_servers "
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We are evaluating (&lt;CODE&gt;eval&lt;/CODE&gt; command) your servers into Server types: ones not wanted and ones targeted.&lt;BR /&gt;
EventID="XYZ" is to be called not_wanted_servers, and everything else is to be called target_servers.&lt;BR /&gt;
Then we use the &lt;CODE&gt;where&lt;/CODE&gt;, so only look for the targeted ServerType, target_servers.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:06:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-results-from-inner-search-and-then-from-outer/m-p/472535#M132981</guid>
      <dc:creator>efavreau</dc:creator>
      <dc:date>2020-09-30T04:06:56Z</dc:date>
    </item>
  </channel>
</rss>

