<?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: Returning results that match one search but not another in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518800#M146016</link>
    <description>&lt;P&gt;Assuming that event string is a field or could be extracted as a field, try&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="your index" sourcetype="your sourcetype" (event="string1" OR event="string2") ("other conditions including time")
|eventstats values(event) as events by ref
|where mvcount(events) &amp;lt;2 AND event="string1" &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please provide some sample events after masking any sensitive data.&lt;/P&gt;</description>
    <pubDate>Thu, 10 Sep 2020 07:35:26 GMT</pubDate>
    <dc:creator>renjith_nair</dc:creator>
    <dc:date>2020-09-10T07:35:26Z</dc:date>
    <item>
      <title>Returning results that match one search but not another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518794#M146012</link>
      <description>&lt;P&gt;I have the following query working in SQL and am struggling to get a working Splunk query that will return the same result set. SQL as follows:&lt;/P&gt;&lt;P&gt;SELECT logA.ref, to_char(logA.edate, 'DD-MON-YYYY HH24:MI:SS') as edate&lt;BR /&gt;FROM logger logA&lt;BR /&gt;WHERE logA.event = 'string1'&lt;BR /&gt;AND sysdate &amp;gt; logA.adate&lt;BR /&gt;&lt;BR /&gt;AND NOT EXISTS (SELECT logB.ref FROM logger logB&lt;BR /&gt;WHERE logB.event like 'string2'&lt;BR /&gt;AND logB.foo = 'bar'&lt;BR /&gt;AND logB.ref = logA.ref)&lt;BR /&gt;order by ref desc&lt;BR /&gt;&lt;BR /&gt;Essentially I want a table of all events that match search1, but only if there is no events in search2 that have the same value for 'ref' as search1.&lt;BR /&gt;&lt;BR /&gt;The data is a single sourcetype in a single index.&lt;BR /&gt;&lt;BR /&gt;I've tried both subsearch and join but have not had any luck. Any tips would be appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 04:35:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518794#M146012</guid>
      <dc:creator>bnwww</dc:creator>
      <dc:date>2020-09-10T04:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Returning results that match one search but not another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518800#M146016</link>
      <description>&lt;P&gt;Assuming that event string is a field or could be extracted as a field, try&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="your index" sourcetype="your sourcetype" (event="string1" OR event="string2") ("other conditions including time")
|eventstats values(event) as events by ref
|where mvcount(events) &amp;lt;2 AND event="string1" &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please provide some sample events after masking any sensitive data.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 07:35:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518800#M146016</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2020-09-10T07:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: Returning results that match one search but not another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518803#M146019</link>
      <description>&lt;P&gt;I have come up with below, give a try:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=yourindex event=string1 NOT (event=string2 foo=bar) 
| stats count by ref,edate 
| sort 0 - ref&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 05:24:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518803#M146019</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2020-09-10T05:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: Returning results that match one search but not another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518808#M146024</link>
      <description>&lt;P&gt;Events have this format:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"ref" : "abcdefg001",&lt;BR /&gt;"somekey" : "somevalue",&lt;BR /&gt;"otherkey" : "othervalue",&lt;BR /&gt;"event" : "string1",&lt;BR /&gt;"edate" : "20100101114512345",&lt;BR /&gt;"adate" : "20100101123000",&lt;BR /&gt;"foo" : "bar"&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 06:03:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518808#M146024</guid>
      <dc:creator>bnwww</dc:creator>
      <dc:date>2020-09-10T06:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: Returning results that match one search but not another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518810#M146026</link>
      <description>&lt;P&gt;Thanks Thambisetty. This gives me a count of each event ref where the event does not have 'string2' in event and&amp;nbsp; 'bar' in foo, but isn't quite what I'm after.&lt;BR /&gt;&lt;BR /&gt;I need to return the set of events that match 'event=string1' *and also*, where the ref for those matched events is not found in any another event matching 'event=string2 and foo=bar'.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 06:12:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518810#M146026</guid>
      <dc:creator>bnwww</dc:creator>
      <dc:date>2020-09-10T06:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: Returning results that match one search but not another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518812#M146028</link>
      <description>&lt;P&gt;'event' is a field, as is ref, edate, adate.&lt;BR /&gt;&lt;BR /&gt;Running your suggested query without the 'where eventCount &amp;gt; 2' line, I have all six events of 'event=string1' returned. Note there are no 'event=string2' events in the data set (as we're trying to match NOT EXIST on that event type).&lt;BR /&gt;&lt;BR /&gt;Running it with the 'where eventCount &amp;gt; 2' line gives me zero results.&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to return the set of events that match 'event=string1' *and also*, where the ref for those matched events is not found in any another event matching 'event=string2 and foo=bar'.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 06:19:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518812#M146028</guid>
      <dc:creator>bnwww</dc:creator>
      <dc:date>2020-09-10T06:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: Returning results that match one search but not another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518815#M146031</link>
      <description>&lt;P&gt;sorry there was a minor error where values should be replaced by dc.&lt;/P&gt;&lt;P&gt;Nevertheless, what do you mean by "there are no 'event=string2' " , are you not including in the search ?&lt;/P&gt;&lt;P&gt;What we are trying to do is,&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Collect all events (both string1 and string 2) using OR&lt;/LI&gt;&lt;LI&gt;Count the presence of event by &lt;EM&gt;eventstats&lt;/EM&gt; by ref -&amp;gt; This should give 2 for those ref which are part of both events (string1 and string2) and 1 for those ref which are part of only string1 OR string2&lt;/LI&gt;&lt;LI&gt;Filter the events with&lt;EM&gt; where eventCount &amp;lt; 2 &lt;/EM&gt;so that&amp;nbsp; only events with string1 OR string2&lt;/LI&gt;&lt;LI&gt;Finally &lt;EM&gt;AND event=string1&lt;/EM&gt; should filter out all events with string2&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 06:34:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518815#M146031</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2020-09-10T06:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Returning results that match one search but not another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518821#M146032</link>
      <description>&lt;P&gt;sample events:&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"ref" : "a",&lt;BR /&gt;"somekey" : "somevalue",&lt;BR /&gt;"otherkey" : "othervalue",&lt;BR /&gt;"event" : "string1",&lt;BR /&gt;"edate" : "20100101114512345",&lt;BR /&gt;"adate" : "20100101123000",&lt;BR /&gt;"foo" : "bar"&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;"ref" : "b",&lt;BR /&gt;"somekey" : "somevalue",&lt;BR /&gt;"otherkey" : "othervalue",&lt;BR /&gt;"event" : "string1",&lt;BR /&gt;"edate" : "20100101114512345",&lt;BR /&gt;"adate" : "20100101123000",&lt;BR /&gt;"foo" : "sheep"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"ref" : "c",&lt;BR /&gt;"somekey" : "somevalue",&lt;BR /&gt;"otherkey" : "othervalue",&lt;BR /&gt;"event" : "string2",&lt;BR /&gt;"edate" : "20100101114512345",&lt;BR /&gt;"adate" : "20100101123000",&lt;BR /&gt;"foo" : "bar"&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;"ref" : "a",&lt;BR /&gt;"somekey" : "somevalue",&lt;BR /&gt;"otherkey" : "othervalue",&lt;BR /&gt;"event" : "string2",&lt;BR /&gt;"edate" : "20100101114512345",&lt;BR /&gt;"adate" : "20100101123000",&lt;BR /&gt;"foo" : "bar"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;and search :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;source="s5.txt"  sourcetype="_json"
| table event,ref,foo
| eval type=case(event=="string1","search1",event=="string2" AND foo=="bar","search2")
| eventstats dc(type) as dc_type by ref
| search type=search1 OR (dc_type=1 type=search2)&lt;/LI-CODE&gt;&lt;P&gt;created a field called type and it will have two values : 1st value when event matches string1 and second value when event matches string2 and foo matches bar.&lt;BR /&gt;eventstats is to find matches of those two types in events based on ref&lt;/P&gt;&lt;P&gt;finally filter search is where we define what we need : type = search1 returns where event=string1 OR events that are matched with type search2 and their ref is not found in type search1.&lt;/P&gt;&lt;P&gt;hope this is what you are looking for. let me know if my understanding is wrong.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 06:47:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518821#M146032</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2020-09-10T06:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: Returning results that match one search but not another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518825#M146034</link>
      <description>&lt;P&gt;Thanks renjith_nair, I edited the search to use dc but still no joy.&lt;/P&gt;&lt;P&gt;When I say "there are no 'event=string2'" events, I mean that the second search - 'event=string2 AND foo=bar' - should not match any events, as there are none in the index that match this query.&lt;/P&gt;&lt;P&gt;What I am trying to do is find Splunk events that have "event=string1", *and that do not have* a corresponding separate event with 'event=string2 and foo=bar'. The 'corresponding' part comes through matching the value of the 'ref' field.&lt;/P&gt;&lt;P&gt;If there is a Splunk event with 'event=string1' and there is also a corresponding separate 'event=string2 and foo=bar' - corresponding as evidenced by both Splunk events having the same value in their 'ref' field - then we don't want to show that data in our results.&lt;/P&gt;&lt;P&gt;Think of it like looking for TCP 'syn' packets that don't have a corresponding 'ack' packet: we don't want to show tcp flows where we have SYN/ACK, just ones where we have SYN and no corresponding ACK.&lt;BR /&gt;&lt;BR /&gt;I have six events that match 'event=string1' and zero events matching 'event=string2 AND foo=bar', so I would expect all six to be included in the count, but I'm seeing zero events even after changing from value to dc.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 06:58:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518825#M146034</guid>
      <dc:creator>bnwww</dc:creator>
      <dc:date>2020-09-10T06:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: Returning results that match one search but not another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518836#M146041</link>
      <description>&lt;P&gt;Alright, could you please share the result of below&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="your index" sourcetype="your sourcetype" (event="string1" OR event="string2") ("other conditions including time")
|eventstats values(event) as eventList by ref
|eval dcEvent=mvcount(eventList)|table ref,event,eventList,dcEvent&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 07:38:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518836#M146041</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2020-09-10T07:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Returning results that match one search but not another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518837#M146042</link>
      <description>&lt;P&gt;Thanks Thambisetty, I think this is close.&lt;BR /&gt;&lt;BR /&gt;"eventstats is to find matches of those two types in events based on ref"&lt;BR /&gt;&lt;BR /&gt;Running your query I get all six expected events returned. Field 'dc_type' is 1.&lt;BR /&gt;&lt;BR /&gt;Would I be correct in assuming that, once I have events of "event=string2 and foo=bar" that also have a ref value that matches an event with 'event=string1', I would see 'dc_type = 2' for that event?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 07:41:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518837#M146042</guid>
      <dc:creator>bnwww</dc:creator>
      <dc:date>2020-09-10T07:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Returning results that match one search but not another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518844#M146045</link>
      <description>&lt;P&gt;No results found&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 08:09:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518844#M146045</guid>
      <dc:creator>bnwww</dc:creator>
      <dc:date>2020-09-10T08:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Returning results that match one search but not another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518845#M146046</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/226070"&gt;@bnwww&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Would I be correct in assuming that, once I have events of "event=string2 and foo=bar" that also have a ref value that matches an event with 'event=string1', I would see 'dc_type = 2' for that event?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;you are right , but you don't want to get this in results as per your first question right ?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 08:25:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518845#M146046</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2020-09-10T08:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Returning results that match one search but not another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518854#M146053</link>
      <description>&lt;P&gt;That's right. Just checking I had a correct understanding of how it worked.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 08:50:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518854#M146053</guid>
      <dc:creator>bnwww</dc:creator>
      <dc:date>2020-09-10T08:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Returning results that match one search but not another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518856#M146054</link>
      <description />
      <pubDate>Thu, 10 Sep 2020 08:57:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/518856#M146054</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2020-09-10T08:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Returning results that match one search but not another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/519807#M146388</link>
      <description>&lt;P&gt;Thank you thambisetty. Here is the slightly modified version that worked for my use case:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=myindex sourcetype=mysourcetype
| table event,ref,foo
| eval type=case(event=="string1","search1",event=="string2" AND foo=="bar","search2")
| eventstats dc(type) as dc_type by ref
| search dc_type=1 AND type=search1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;This returns only events that match the following criteria:&lt;BR /&gt;&lt;BR /&gt;1. They have 'string1' as their event&lt;BR /&gt;2. They do not have a corresponding 'event=string2 AND foo=bar' event, with&amp;nbsp;'corresponding' in this case being determined by the ref field via&amp;nbsp; 'as dc_type by ref'.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 01:34:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Returning-results-that-match-one-search-but-not-another/m-p/519807#M146388</guid>
      <dc:creator>bnwww</dc:creator>
      <dc:date>2020-09-16T01:34:43Z</dc:date>
    </item>
  </channel>
</rss>

