<?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 can I obtain a list of values returned by one query, but not another? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374948#M110184</link>
    <description>&lt;P&gt;I have one query that returns SESSION_IDs of attempted orders:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index "abc" | rex field=_raw "(?&amp;lt;SESSION_ID&amp;gt;pattern)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I have a second query that returns SESSION_IDs of successful orders:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index "def" | rex field=_raw "(?&amp;lt;SESSION_ID&amp;gt;pattern)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do return the list of SESSION_IDs returned by the first query that are not returned by the second query? I assume this involves using a subsearch with the NOT keyword, but I can't figure out how to do it.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;BR /&gt;
Jonathan&lt;/P&gt;</description>
    <pubDate>Thu, 22 Mar 2018 19:08:21 GMT</pubDate>
    <dc:creator>jbrenner</dc:creator>
    <dc:date>2018-03-22T19:08:21Z</dc:date>
    <item>
      <title>How can I obtain a list of values returned by one query, but not another?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374948#M110184</link>
      <description>&lt;P&gt;I have one query that returns SESSION_IDs of attempted orders:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index "abc" | rex field=_raw "(?&amp;lt;SESSION_ID&amp;gt;pattern)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I have a second query that returns SESSION_IDs of successful orders:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index "def" | rex field=_raw "(?&amp;lt;SESSION_ID&amp;gt;pattern)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do return the list of SESSION_IDs returned by the first query that are not returned by the second query? I assume this involves using a subsearch with the NOT keyword, but I can't figure out how to do it.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;BR /&gt;
Jonathan&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 19:08:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374948#M110184</guid>
      <dc:creator>jbrenner</dc:creator>
      <dc:date>2018-03-22T19:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can I obtain a list of values returned by one query, but not another?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374949#M110185</link>
      <description>&lt;P&gt;Try something like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index "abc" NOT [search index=my_index "def" | rex "(?&amp;lt;SESSION_ID&amp;gt;pattern)" | fields SESSION_ID | format] | rex "(?&amp;lt;SESSION_ID&amp;gt;pattern)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Depending on what you want to do with the events you could add &lt;CODE&gt;| stats count by SESSION_ID&lt;/CODE&gt; or something similar.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 19:24:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374949#M110185</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-03-22T19:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can I obtain a list of values returned by one query, but not another?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374950#M110186</link>
      <description>&lt;P&gt;Hi Rich,&lt;BR /&gt;
Thanks for the answer.  I tried your suggestion, but I'm getting the following error:&lt;/P&gt;

&lt;P&gt;Error in 'rex' command: Invalid argument: 'NOT'&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 20:12:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374950#M110186</guid>
      <dc:creator>jbrenner</dc:creator>
      <dc:date>2018-03-22T20:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I obtain a list of values returned by one query, but not another?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374951#M110187</link>
      <description>&lt;P&gt;I assume I also need at least one "stats count by SESSION_ID" somewhere in the query to get a unique list of SESSION_IDs, but I'm not sure where it needs to go.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:39:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374951#M110187</guid>
      <dc:creator>jbrenner</dc:creator>
      <dc:date>2020-09-29T18:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can I obtain a list of values returned by one query, but not another?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374952#M110188</link>
      <description>&lt;P&gt;Why do not you try &lt;BR /&gt;
I assume both the keywords are in same index&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=my_index "abc" NOT "def" | rex field=_raw "(?&amp;lt;SESSION_ID&amp;gt;pattern)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index "abc" 
| rex field=_raw "(?&amp;lt;SESSION_ID&amp;gt;pattern)" 
| stats count as "Attempted" by SESSION_ID 
| eval SESSION_ID1=SESSION_ID 
| eval status1="Active" 
| join SESSION_ID1 type=outer 
    [ search index=my_index "def" 
    | rex field=_raw "(?&amp;lt;SESSION_ID&amp;gt;pattern)" 
    | stats count as "Successful" by SESSION_ID 
    | eval SESSION_ID1=SESSION_ID 
    | eval status2 = "Active" ] 
| eval Status = if(match(status1,status2), "Active", "Not_in_list") 
| table SESSION_ID1 Status 
| where Status="Not_in_list"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 03:20:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374952#M110188</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-03-23T03:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: How can I obtain a list of values returned by one query, but not another?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374953#M110189</link>
      <description>&lt;P&gt;Thanks for pointing out my error.  I fixed my answer.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 03:58:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374953#M110189</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-03-23T03:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: How can I obtain a list of values returned by one query, but not another?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374954#M110190</link>
      <description>&lt;P&gt;Hi Rich, I tried your latest query and added  "| stats count by SESSION_ID" to the end, and it runs now, but it's returning the SESSION_IDs of all attempted orders, so the NOT doesn't seem to be working correctly.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Jonathan&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:38:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374954#M110190</guid>
      <dc:creator>jbrenner</dc:creator>
      <dc:date>2020-09-29T18:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: How can I obtain a list of values returned by one query, but not another?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374955#M110191</link>
      <description>&lt;P&gt;Hi Mayur. Thanks for responding. I don't see how the first example would work, because the attempts and successes are in separate log statements.&lt;BR /&gt;
I was able to get your second example to run, but it's returning the SESSION_IDs of all attempted orders instead of just the failed ones.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 17:20:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374955#M110191</guid>
      <dc:creator>jbrenner</dc:creator>
      <dc:date>2018-03-23T17:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: How can I obtain a list of values returned by one query, but not another?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374956#M110192</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/196448"&gt;@jbrenner&lt;/a&gt; what mayur said is correct in you case you need to replace the = with != &lt;/P&gt;

&lt;P&gt;[ search index=my_index "def" &lt;BR /&gt;
     | rex field=_raw "(?&lt;SESSION_ID&gt;pattern)" &lt;BR /&gt;
     | stats count as "Successful" by SESSION_ID &lt;BR /&gt;
     &lt;STRONG&gt;| eval SESSION_ID1=SESSION_ID&lt;/STRONG&gt; &lt;BR /&gt;
     | eval status2 = "Active" ] &lt;/SESSION_ID&gt;&lt;/P&gt;

&lt;P&gt;with &lt;STRONG&gt;| eval SESSION_ID1!=SESSION_ID&lt;/STRONG&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:58:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-obtain-a-list-of-values-returned-by-one-query-but-not/m-p/374956#M110192</guid>
      <dc:creator>dsha</dc:creator>
      <dc:date>2020-09-29T21:58:53Z</dc:date>
    </item>
  </channel>
</rss>

