<?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 create a search and subsearch to exclude results in a query? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-and-subsearch-to-exclude-results-in-a/m-p/617459#M214584</link>
    <description>&lt;P&gt;I need to create a search and subsearch to exclude results in a query.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the primary search is a lookup table. the subsearch is a query on events that extracts a field I want to use to join to the primary search. the common field is hostname.&lt;/P&gt;
&lt;P&gt;If a given hostname in the lookup table is found in the subsearch i want to discard it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;primary search&lt;/P&gt;
&lt;P&gt;| inputlookup hosts.csv&lt;/P&gt;
&lt;P&gt;field = hostname&lt;/P&gt;
&lt;P&gt;output:&lt;/P&gt;
&lt;P&gt;host1&lt;/P&gt;
&lt;P&gt;host2&lt;/P&gt;
&lt;P&gt;host3&lt;/P&gt;
&lt;P&gt;subsearch&lt;/P&gt;
&lt;P&gt;index=abc message="for account" sourcetype=type1&lt;/P&gt;
&lt;P&gt;rex field=names"(?&amp;lt;hostname&amp;gt;\S+)&lt;/P&gt;
&lt;P&gt;field hostname&lt;/P&gt;
&lt;P&gt;output:&lt;/P&gt;
&lt;P&gt;host3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want the following output:&lt;/P&gt;
&lt;P&gt;&lt;U&gt;hostname&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;host1&lt;/P&gt;
&lt;P&gt;host2&lt;/P&gt;
&lt;P&gt;I want to discard host3 since its in the subquery.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I correlate the searches to do this? I can't use&amp;nbsp; a join because the hostname in the subsearch is not computed until the subquery is executed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in Advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Oct 2022 13:59:05 GMT</pubDate>
    <dc:creator>pc1234</dc:creator>
    <dc:date>2022-10-18T13:59:05Z</dc:date>
    <item>
      <title>How to create a search and subsearch to exclude results in a query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-and-subsearch-to-exclude-results-in-a/m-p/617459#M214584</link>
      <description>&lt;P&gt;I need to create a search and subsearch to exclude results in a query.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the primary search is a lookup table. the subsearch is a query on events that extracts a field I want to use to join to the primary search. the common field is hostname.&lt;/P&gt;
&lt;P&gt;If a given hostname in the lookup table is found in the subsearch i want to discard it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;primary search&lt;/P&gt;
&lt;P&gt;| inputlookup hosts.csv&lt;/P&gt;
&lt;P&gt;field = hostname&lt;/P&gt;
&lt;P&gt;output:&lt;/P&gt;
&lt;P&gt;host1&lt;/P&gt;
&lt;P&gt;host2&lt;/P&gt;
&lt;P&gt;host3&lt;/P&gt;
&lt;P&gt;subsearch&lt;/P&gt;
&lt;P&gt;index=abc message="for account" sourcetype=type1&lt;/P&gt;
&lt;P&gt;rex field=names"(?&amp;lt;hostname&amp;gt;\S+)&lt;/P&gt;
&lt;P&gt;field hostname&lt;/P&gt;
&lt;P&gt;output:&lt;/P&gt;
&lt;P&gt;host3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want the following output:&lt;/P&gt;
&lt;P&gt;&lt;U&gt;hostname&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;host1&lt;/P&gt;
&lt;P&gt;host2&lt;/P&gt;
&lt;P&gt;I want to discard host3 since its in the subquery.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I correlate the searches to do this? I can't use&amp;nbsp; a join because the hostname in the subsearch is not computed until the subquery is executed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in Advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 13:59:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-and-subsearch-to-exclude-results-in-a/m-p/617459#M214584</guid>
      <dc:creator>pc1234</dc:creator>
      <dc:date>2022-10-18T13:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-and-subsearch-to-exclude-results-in-a/m-p/617460#M214585</link>
      <description>&lt;P&gt;You wrote what you need to do - a search, a subsearch, and exclude (NOT).&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup hosts.csv where NOT [ index=abc message="for account" sourcetype=type1 | rex field=names"(?&amp;lt;hostname&amp;gt;\S+) ]&lt;/LI-CODE&gt;&lt;P&gt;It also can be done with a join, but that's not preferred.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup hosts.csv
| join type=left hostname [
  index=abc message="for account" sourcetype=type1
  | rex field=names"(?&amp;lt;hostname&amp;gt;\S+) ]&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 17 Oct 2022 23:58:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-search-and-subsearch-to-exclude-results-in-a/m-p/617460#M214585</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-10-17T23:58:12Z</dc:date>
    </item>
  </channel>
</rss>

