<?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 How to write a search to return hosts that have no results in a map search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-return-hosts-that-have-no-results-in-a/m-p/111097#M29091</link>
    <description>&lt;P&gt;I have a search, lets say:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=foo earliest=-1d@d | map search="search host=$host$ earliest=@d sourcetype=bar | count by host | table host, count"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This returns the opposite of what I want, all hosts from the first search that have results in the mapped search.&lt;/P&gt;

&lt;P&gt;I'm interested in the opposite. I want hosts that return from &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=foo earliest=-1d@d &lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;which don't have any events in the mapped search&lt;/P&gt;

&lt;P&gt;Is there a way to achieve this?&lt;/P&gt;</description>
    <pubDate>Tue, 11 Nov 2014 23:49:09 GMT</pubDate>
    <dc:creator>ollie920049</dc:creator>
    <dc:date>2014-11-11T23:49:09Z</dc:date>
    <item>
      <title>How to write a search to return hosts that have no results in a map search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-return-hosts-that-have-no-results-in-a/m-p/111097#M29091</link>
      <description>&lt;P&gt;I have a search, lets say:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=foo earliest=-1d@d | map search="search host=$host$ earliest=@d sourcetype=bar | count by host | table host, count"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This returns the opposite of what I want, all hosts from the first search that have results in the mapped search.&lt;/P&gt;

&lt;P&gt;I'm interested in the opposite. I want hosts that return from &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=foo earliest=-1d@d &lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;which don't have any events in the mapped search&lt;/P&gt;

&lt;P&gt;Is there a way to achieve this?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Nov 2014 23:49:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-return-hosts-that-have-no-results-in-a/m-p/111097#M29091</guid>
      <dc:creator>ollie920049</dc:creator>
      <dc:date>2014-11-11T23:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to return hosts that have no results in a map search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-return-hosts-that-have-no-results-in-a/m-p/111098#M29092</link>
      <description>&lt;P&gt;I don't think you need to use &lt;CODE&gt;map&lt;/CODE&gt; command there. Maybe try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=foo earliest=-1d@d [ search sourcetype=bar earliest=@d | fields host | dedup host ]
 | stats count by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You should get all content from &lt;CODE&gt;sourcetype=foo&lt;/CODE&gt; that have &lt;EM&gt;host="the hosts from the sub-search"&lt;/EM&gt;. You can easily invert the order of the main and the subsearch if necessary.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Nov 2014 01:49:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-return-hosts-that-have-no-results-in-a/m-p/111098#M29092</guid>
      <dc:creator>musskopf</dc:creator>
      <dc:date>2014-11-12T01:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to return hosts that have no results in a map search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-return-hosts-that-have-no-results-in-a/m-p/111099#M29093</link>
      <description>&lt;P&gt;It worked with your suggestion, however, the dataset I was returning in the subsearch was huge. I tweaked it a little and ended up with the following:&lt;/P&gt;

&lt;P&gt;sourcetype=foo earliest=-1d@d&lt;BR /&gt;
| ... (data needed manipulating before I could filter out hosts)&lt;BR /&gt;
| search NOT [&lt;BR /&gt;
    | metadata type=hosts sourcetype=bar&lt;BR /&gt;&lt;BR /&gt;
    | eval day_ago=relative_time(now(), "-1d") &lt;BR /&gt;
    | where latestTime &amp;gt; day_ago &lt;BR /&gt;
    | fields host&lt;BR /&gt;
    | dedup host&lt;BR /&gt;
    | format ]&lt;BR /&gt;
| table host&lt;/P&gt;

&lt;P&gt;That performed very well. Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:07:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-return-hosts-that-have-no-results-in-a/m-p/111099#M29093</guid>
      <dc:creator>ollie920049</dc:creator>
      <dc:date>2020-09-28T18:07:43Z</dc:date>
    </item>
  </channel>
</rss>

