<?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 search for events that are in one index, but not in another without using a subsearch? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239484#M71145</link>
    <description>&lt;P&gt;I have 3 indexes containing events with IP addresses, index1, index2, and index3.  My goal is to return a list of all IP addresses that are present in index1, but are not present in index2 or index3.&lt;/P&gt;

&lt;P&gt;My current solution finds the IPs that are only in either index1 or (index2 or index3), using set diff, then intersects that result with index1 to limit the IPs to ones in index1:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set intersect [ search index=index1 AND ip earliest=-3d | dedup 1 ip | table ip ] [ | set diff [ search index=index1 AND ip earliest=-3d | dedup 1 ip | table ip ] [ search (index=index2 OR index=index3) AND IpAddr earliest=-5d | dedup 1 IpAddr | rename IpAddr AS ip | table ip ] ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This solution works, except each subsearch returns more than the maximum subsearch limit of 10500 (around 20000 results).&lt;/P&gt;

&lt;P&gt;Does anyone have any idea how this search could be rewritten without using subsearches, to avoid this limitation?&lt;/P&gt;

&lt;P&gt;Thanks for any help or ideas.&lt;/P&gt;</description>
    <pubDate>Wed, 17 Aug 2016 19:03:04 GMT</pubDate>
    <dc:creator>jsilverstein</dc:creator>
    <dc:date>2016-08-17T19:03:04Z</dc:date>
    <item>
      <title>How to search for events that are in one index, but not in another without using a subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239484#M71145</link>
      <description>&lt;P&gt;I have 3 indexes containing events with IP addresses, index1, index2, and index3.  My goal is to return a list of all IP addresses that are present in index1, but are not present in index2 or index3.&lt;/P&gt;

&lt;P&gt;My current solution finds the IPs that are only in either index1 or (index2 or index3), using set diff, then intersects that result with index1 to limit the IPs to ones in index1:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set intersect [ search index=index1 AND ip earliest=-3d | dedup 1 ip | table ip ] [ | set diff [ search index=index1 AND ip earliest=-3d | dedup 1 ip | table ip ] [ search (index=index2 OR index=index3) AND IpAddr earliest=-5d | dedup 1 IpAddr | rename IpAddr AS ip | table ip ] ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This solution works, except each subsearch returns more than the maximum subsearch limit of 10500 (around 20000 results).&lt;/P&gt;

&lt;P&gt;Does anyone have any idea how this search could be rewritten without using subsearches, to avoid this limitation?&lt;/P&gt;

&lt;P&gt;Thanks for any help or ideas.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 19:03:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239484#M71145</guid>
      <dc:creator>jsilverstein</dc:creator>
      <dc:date>2016-08-17T19:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for events that are in one index, but not in another without using a subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239485#M71146</link>
      <description>&lt;P&gt;Hi @jsilverstein&lt;/P&gt;

&lt;P&gt;If you haven't seen this yet, this previous Q&amp;amp;A by @mus might give you some ideas on how to approach this:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html"&gt;https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 19:12:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239485#M71146</guid>
      <dc:creator>ppablo</dc:creator>
      <dc:date>2016-08-17T19:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for events that are in one index, but not in another without using a subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239486#M71147</link>
      <description>&lt;P&gt;The final solution is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;((index=index1 AND ip) OR ((index=index2 OR index=index3) AND IpAddr)) earliest=-3d | dedup ip keepempty=true | dedup IpAddr keepempty=true | eval myIP=coalesce(ip,IpAddr) | eval from_index1=if(index="index1",1,null()) | stats dc(index) AS num_occurences sum(from_index1) AS from_index1 by myIP | where num_occurences=1 AND from_index1=1 | table myIP
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks @mus for your help making this more efficient.&lt;/P&gt;

&lt;P&gt;The first solution took up large amounts of memory (&amp;gt;500MB):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;((index=index1 AND ip) OR ((index=index2 OR index=index3) AND IpAddr)) earliest=-3d | dedup IpAddr keepempty=true | stats values(ip) AS ips values(IpAddr) AS ips2 | mvexpand ips | eval result=if(match(ips2, ips),"YES","NO") | where result="NO" | table ips
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks @ppablo for the helpful link and the quick response.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 21:42:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239486#M71147</guid>
      <dc:creator>jsilverstein</dc:creator>
      <dc:date>2016-08-17T21:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for events that are in one index, but not in another without using a subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239487#M71148</link>
      <description>&lt;P&gt;Awesome, I'm glad the link helped you come up with an efficient search &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thanks for sharing your final solution with the community, and welcome to Splunk Answers!&lt;/P&gt;

&lt;P&gt;Cheers&lt;BR /&gt;
Patrick&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 22:01:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239487#M71148</guid>
      <dc:creator>ppablo</dc:creator>
      <dc:date>2016-08-17T22:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for events that are in one index, but not in another without using a subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239488#M71149</link>
      <description>&lt;P&gt;Always good to see that my Q&amp;amp;A is helpful &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 22:08:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239488#M71149</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-08-17T22:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for events that are in one index, but not in another without using a subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239489#M71150</link>
      <description>&lt;P&gt;This search uses a significant amount of memory (&amp;gt;500MB).  It appears that the output from &lt;CODE&gt;values(IpAddr) AS ips2&lt;/CODE&gt; is duplicated in memory for each &lt;CODE&gt;values(ip) AS ips&lt;/CODE&gt; when &lt;CODE&gt;mvexpand ips&lt;/CODE&gt; is executed.  Is there a way to force Splunk to store only 1 copy of &lt;CODE&gt;values(IpAddr)&lt;/CODE&gt; in memory?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 22:51:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239489#M71150</guid>
      <dc:creator>jsilverstein</dc:creator>
      <dc:date>2016-08-17T22:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for events that are in one index, but not in another without using a subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239490#M71151</link>
      <description>&lt;P&gt;Yes, &lt;CODE&gt;mvexpand&lt;/CODE&gt; is the down side in this example ... Maybe a different approach could help here; How about counting the number of times an IP appears in the indexes and compare it that way?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;((index=index1 AND ip) OR ((index=index2 OR index=index3) AND IpAddr)) earliest=-3d 
| dedup IpAddr keepempty=true
| eval myIP = coalesce(ip,IpAddr) 
| stats dc(index) AS c_idx by myIP 
| where c_idx = 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should show only IP's that are in one index.&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 23:13:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239490#M71151</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-08-17T23:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for events that are in one index, but not in another without using a subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239491#M71152</link>
      <description>&lt;P&gt;I really like that idea; it seems really clean and simple.  But I need the result to be IPs that are only in index1, with no IPs that are only in index2 or index3.  Any thoughts how I could achieve this?  Maybe a function similar to coalesce that could additionally assign a label, or maybe through an eval of some sort?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 23:32:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239491#M71152</guid>
      <dc:creator>jsilverstein</dc:creator>
      <dc:date>2016-08-17T23:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for events that are in one index, but not in another without using a subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239492#M71153</link>
      <description>&lt;P&gt;&lt;CODE&gt;eval&lt;/CODE&gt; is your friend &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval c_idx1=if(index="index1", 1, null())
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and change the &lt;CODE&gt;stats&lt;/CODE&gt; and the &lt;CODE&gt;where&lt;/CODE&gt; to be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | stats dc(idx) AS c_idx sum(c_idx1) AS c_idx1 by myIP
 | where c_idx=1 AND c_idx1=1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 23:41:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239492#M71153</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-08-17T23:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for events that are in one index, but not in another without using a subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239493#M71154</link>
      <description>&lt;P&gt;Thanks a lot for your help.  I learned a bunch.  I'll update the answer when I get the final solution finished.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 23:58:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-events-that-are-in-one-index-but-not-in/m-p/239493#M71154</guid>
      <dc:creator>jsilverstein</dc:creator>
      <dc:date>2016-08-17T23:58:54Z</dc:date>
    </item>
  </channel>
</rss>

