<?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 write a search with an outer join to only return results from index=A that are not found in index=B? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286076#M86596</link>
    <description>&lt;P&gt;You may want to filter the fields that come back with the subsearch  or you risk excluding duplicates other than the filename. EG&lt;/P&gt;

&lt;P&gt;index=A tag="tagM" NOT [ search index=B tag="tagY" | fields filename]&lt;/P&gt;</description>
    <pubDate>Mon, 21 Dec 2015 18:13:18 GMT</pubDate>
    <dc:creator>jplumsdaine22</dc:creator>
    <dc:date>2015-12-21T18:13:18Z</dc:date>
    <item>
      <title>How to write a search with an outer join to only return results from index=A that are not found in index=B?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286072#M86592</link>
      <description>&lt;P&gt;I'm looking for the join syntax for an outer join in Splunk that is not "all of A and all of B that's in A".  Rather, what I need is "all of A that's not in B."&lt;/P&gt;

&lt;P&gt;The A and B index records look something like this (simplifying)&lt;/P&gt;

&lt;P&gt;filename=&amp;lt;variable&amp;gt;,&lt;/P&gt;

&lt;P&gt;so the search would have to be something like, where the tag values would be completely different with no overlapping values between the two indexes, however the filename values would overlap.  I want to find filenames in A that are not in B, based on different value for tag in both indexes.&lt;/P&gt;

&lt;P&gt;This is what I'm trying:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A tag="tagM" | join type=left [ search tag="tagY" index=B ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I don't understand how to get the subset of A that's not in B.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Dec 2015 04:17:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286072#M86592</guid>
      <dc:creator>jonbelanger</dc:creator>
      <dc:date>2015-12-19T04:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search with an outer join to only return results from index=A that are not found in index=B?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286073#M86593</link>
      <description>&lt;P&gt;Try with NOT&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A tag="tagM" NOT [ search index=B tag="tagY"]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Dec 2015 12:50:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286073#M86593</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2015-12-19T12:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search with an outer join to only return results from index=A that are not found in index=B?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286074#M86594</link>
      <description>&lt;P&gt;index=B tag="tagY" | join type=outer field1 [search index=A tag="tagM"|eval field2=field1|table field1,field2 ]|search NOT field2=*|table field1&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2015 06:46:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286074#M86594</guid>
      <dc:creator>sameera123</dc:creator>
      <dc:date>2015-12-21T06:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search with an outer join to only return results from index=A that are not found in index=B?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286075#M86595</link>
      <description>&lt;P&gt;If the filename field is common, you shouldn't need a join at all.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=A AND tag="tagM") OR (tag="tagY" AND index=B) | stats values(index) as index by filename 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This search should give you a results table like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;filename | index
aaaa.txt | A
           B
bbbb.txt | A
           B
cccc.txt | A
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then you can append another search like &lt;CODE&gt;| search NOT index=B&lt;/CODE&gt; and you should just see&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;filename | index
cccc.txt | A
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So the full search would be &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=A AND tag="tagM") OR (tag="tagY" AND index=B) | stats values(index) as index by filename  | search NOT index=B
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There's a handy flowchart on which command is best for each situation here: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.2/Search/Abouteventcorrelation"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.2/Search/Abouteventcorrelation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2015 14:37:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286075#M86595</guid>
      <dc:creator>jplumsdaine22</dc:creator>
      <dc:date>2015-12-21T14:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search with an outer join to only return results from index=A that are not found in index=B?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286076#M86596</link>
      <description>&lt;P&gt;You may want to filter the fields that come back with the subsearch  or you risk excluding duplicates other than the filename. EG&lt;/P&gt;

&lt;P&gt;index=A tag="tagM" NOT [ search index=B tag="tagY" | fields filename]&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2015 18:13:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286076#M86596</guid>
      <dc:creator>jplumsdaine22</dc:creator>
      <dc:date>2015-12-21T18:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search with an outer join to only return results from index=A that are not found in index=B?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286077#M86597</link>
      <description>&lt;P&gt;I was able to get this approach to work, but I also had to group the index B results by file name&lt;/P&gt;

&lt;P&gt;index=A tag="tagM" NOT [ search index=B tag="tagY" | stats count by filename | fields filename]&lt;/P&gt;

&lt;P&gt;Without the stats group-by you get results that are still in index B as well as A.  I think this is because "tagY" and filename exists over multiple records that are different values for other fields?  Although I don't completely understand that.&lt;/P&gt;

&lt;P&gt;The group by filters it down to a list all unique filenames as input to the "NOT" search which seems to work.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2015 16:31:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286077#M86597</guid>
      <dc:creator>jonbelanger</dc:creator>
      <dc:date>2015-12-22T16:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search with an outer join to only return results from index=A that are not found in index=B?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286078#M86598</link>
      <description>&lt;P&gt;You can see the difference between &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A tag="tagM" NOT [ search index=B tag="tagY" | stats count by filename | fields filename]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A tag="tagM" NOT [ search index=B tag="tagY" | fields filename]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if you check the remoteSearch field in the Job Inspector. You will see the full output of the expanded subsearch. Also try &lt;CODE&gt;dedup filename&lt;/CODE&gt; as opposed to  &lt;CODE&gt;stats count by filename&lt;/CODE&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2015 17:04:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286078#M86598</guid>
      <dc:creator>jplumsdaine22</dc:creator>
      <dc:date>2015-12-22T17:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search with an outer join to only return results from index=A that are not found in index=B?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286079#M86599</link>
      <description>&lt;P&gt;Both the first response and this response are logically equivalent.  However, this response does not use a subsearch which can be truncated to 10000, invalidating results.  This method is also slightly faster.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2015 20:27:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286079#M86599</guid>
      <dc:creator>jonbelanger</dc:creator>
      <dc:date>2015-12-22T20:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search with an outer join to only return results from index=A that are not found in index=B?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286080#M86600</link>
      <description>&lt;P&gt;Although this one has the drawback of not being able to bring additional fields through.  The whole key to this is that the index field becomes multivalued with the value of either index name.  You can't do the stats by values other than filename because that will throw off the file index search.  &lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2015 20:52:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286080#M86600</guid>
      <dc:creator>jonbelanger</dc:creator>
      <dc:date>2015-12-22T20:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search with an outer join to only return results from index=A that are not found in index=B?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286081#M86601</link>
      <description>&lt;P&gt;If you want to bring all the fields through, use &lt;CODE&gt;| stats values(*) as * by filename  |&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2015 10:09:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286081#M86601</guid>
      <dc:creator>jplumsdaine22</dc:creator>
      <dc:date>2015-12-23T10:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search with an outer join to only return results from index=A that are not found in index=B?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286082#M86602</link>
      <description>&lt;P&gt;Yes, I think dedup and stats are logically equivalent, but I'm running into the maxout default limit for subsearch.  Will fix that soon.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2015 16:53:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286082#M86602</guid>
      <dc:creator>jonbelanger</dc:creator>
      <dc:date>2015-12-23T16:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search with an outer join to only return results from index=A that are not found in index=B?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286083#M86603</link>
      <description>&lt;P&gt;This is exactly what I needed, thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2015 18:55:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-with-an-outer-join-to-only-return-results/m-p/286083#M86603</guid>
      <dc:creator>jonbelanger</dc:creator>
      <dc:date>2015-12-23T18:55:43Z</dc:date>
    </item>
  </channel>
</rss>

