<?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 search for values not present in the lookup table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406372#M117469</link>
    <description>&lt;P&gt;So I have a producer and consumer tables which will be having the same trackingId's every time. If a tracking Id is been missed in the consumer table. But it is present in the Producer table. Then I need those values of the trackingIDs which are missed.&lt;/P&gt;</description>
    <pubDate>Fri, 12 Apr 2019 21:27:45 GMT</pubDate>
    <dc:creator>akarunkumar321</dc:creator>
    <dc:date>2019-04-12T21:27:45Z</dc:date>
    <item>
      <title>How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406362#M117459</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I Have a &lt;CODE&gt;table-1&lt;/CODE&gt; with tracking IDs ex: &lt;CODE&gt;123, 456, 789&lt;/CODE&gt; and the other query which returns a &lt;CODE&gt;table-2&lt;/CODE&gt; with tracking ID's ex: &lt;CODE&gt;456, 789&lt;/CODE&gt;. &lt;BR /&gt;
Now, I need a query which gives me a &lt;CODE&gt;table-3&lt;/CODE&gt;  with the values which are not present in &lt;CODE&gt;table-2&lt;/CODE&gt; when compared with the &lt;CODE&gt;table -1&lt;/CODE&gt;. I tried something like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; source=service1.log  earliest=-4h latest=now() | rex field=_raw "trackingId\":\s\"(?[\w-]+)\""  | table ProducerTrackingID |  search NOT [search source=service2.log  earliest=-4h latest=now() | rex field=_raw "trackingId\":\s\"(?[\w-]+)\"" | table ConsumerTrackingID]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can you please explain me the query. And Thanks a lot in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 22:40:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406362#M117459</guid>
      <dc:creator>akarunkumar321</dc:creator>
      <dc:date>2019-04-11T22:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406363#M117460</link>
      <description>&lt;P&gt;Where is the lookup table in your query, do you want the results based on lookup or index?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 00:04:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406363#M117460</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-04-12T00:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406364#M117461</link>
      <description>&lt;P&gt;index=ccp source=service1.log  earliest=-4h latest=now() | rex field=_raw "trackingId\":\s\"(?[\w-]+)\""  | table ProducerTrackingID | search NOT [search index=service2.log earliest=-4h latest=now() | rex field=_raw "trackingId\":\s\"(?[\w-]+)\"" | table ConsumerTrackingID]. The lookuptable is ConsumerTrackingID. I want the values which are not present in the ConsumerTrackingID Table.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:05:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406364#M117461</guid>
      <dc:creator>akarunkumar321</dc:creator>
      <dc:date>2020-09-30T00:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406365#M117462</link>
      <description>&lt;P&gt;@akarunkumar321 can you try splunk joins here&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 05:18:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406365#M117462</guid>
      <dc:creator>raj_mpl</dc:creator>
      <dc:date>2019-04-12T05:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406366#M117463</link>
      <description>&lt;P&gt;@akarunkumar321 , You can try the below query and let me know &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ccp source=service1.log earliest=-4h latest=now() | rex field=_raw "trackingId\":\s\"(?[\w-]+)\"" | table ProducerTrackingID |join type=outer ProducerTrackingID [search index=service2.log earliest=-4h latest=now() | rex field=_raw "trackingId\":\s\"(?[\w-]+)\""|rename ConsumerTrackingID as ProducerTrackingID]|search NOT source=service1.log
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Apr 2019 05:30:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406366#M117463</guid>
      <dc:creator>raj_mpl</dc:creator>
      <dc:date>2019-04-12T05:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406367#M117464</link>
      <description>&lt;P&gt;Hi @raj_mpl,&lt;BR /&gt;
    Could you please try below splunk "set" command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set diff [&amp;lt;first-query&amp;gt;] [&amp;lt;second-query&amp;gt;]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is one small example.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set diff [| makeresults | eval ID="10" | append [| makeresults | eval ID="15"] | table ID] [| makeresults | eval ID="10" | table ID]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Apr 2019 05:36:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406367#M117464</guid>
      <dc:creator>VatsalJagani</dc:creator>
      <dc:date>2019-04-12T05:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406368#M117465</link>
      <description>&lt;P&gt;This one giving me all the values in the table ProducerTrackingID. Before that, in the subquery search, we are just renaming the ConsumerTrackingID to be ProducerTrackingID. Do we don't require a table to hold these values?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 20:38:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406368#M117465</guid>
      <dc:creator>akarunkumar321</dc:creator>
      <dc:date>2019-04-12T20:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406369#M117466</link>
      <description>&lt;P&gt;@akarunkumar321 I am still not clear on the question. The current query you have written, searches on 2 different indexes , I believe your subsearch says index=service2.log which looks like should be source=service2.log and index=ccp. &lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 21:07:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406369#M117466</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-04-12T21:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406370#M117467</link>
      <description>&lt;P&gt;Sorry for the confusion both of them has the same index&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 21:09:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406370#M117467</guid>
      <dc:creator>akarunkumar321</dc:creator>
      <dc:date>2019-04-12T21:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406371#M117468</link>
      <description>&lt;P&gt;so is this query working fine? do you need the tracking id from this query to be compared against lookup table ?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 21:16:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406371#M117468</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-04-12T21:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406372#M117469</link>
      <description>&lt;P&gt;So I have a producer and consumer tables which will be having the same trackingId's every time. If a tracking Id is been missed in the consumer table. But it is present in the Producer table. Then I need those values of the trackingIDs which are missed.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 21:27:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406372#M117469</guid>
      <dc:creator>akarunkumar321</dc:creator>
      <dc:date>2019-04-12T21:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406373#M117470</link>
      <description>&lt;P&gt;Your query itself should work. Are you getting the tracking I’d valued correctly with your red command , have you tested it. What is the output you are getting with your query ? Also when you run individual query do you get tracking id values ?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 21:39:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406373#M117470</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-04-12T21:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406374#M117471</link>
      <description>&lt;P&gt;No, it is not working, When I run the main query and subquery separately they both give me the tables with the values but whereas if I run it together in the subquery it always returns me the producer table with the trackingId values.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 22:01:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406374#M117471</guid>
      <dc:creator>akarunkumar321</dc:creator>
      <dc:date>2019-04-12T22:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406375#M117472</link>
      <description>&lt;P&gt;Try this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=service1.log earliest=-4h latest=now() | rex field=_raw "trackingId\":\s\"(?[\w-]+)\"" | table ProducerTrackingID | search NOT [search source=service2.log earliest=-4h latest=now() | rex field=_raw "trackingId\":\s\"(?[\w-]+)\"" | table ConsumerTrackingID| rename ConsumerTrackingID as ProducerTrackingID]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Apr 2019 22:31:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406375#M117472</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-04-12T22:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406376#M117473</link>
      <description>&lt;P&gt;Ok, I tried out the query which you have suggested. If you look into the image on the top left corner which I have shared you it shows me 5 events. Basically, it should be zero because I ran the query separately and all the tracking Id from the producer are present in the consumer service. &lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 22:46:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406376#M117473</guid>
      <dc:creator>akarunkumar321</dc:creator>
      <dc:date>2019-04-12T22:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406377#M117474</link>
      <description>&lt;P&gt;That worked out. Thanks a lot. can we see producerTrackingId's and CosnumerTrackingId's in the different table as well?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 22:54:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406377#M117474</guid>
      <dc:creator>akarunkumar321</dc:creator>
      <dc:date>2019-04-12T22:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406378#M117475</link>
      <description>&lt;P&gt;That worked out. Thanks a lot. can we see producerTrackingId's and CosnumerTrackingId's in a different table as well?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 22:54:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406378#M117475</guid>
      <dc:creator>akarunkumar321</dc:creator>
      <dc:date>2019-04-12T22:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406379#M117476</link>
      <description>&lt;P&gt;You already have them in 2 different indexes and you are doing this query to get the third list based on 2 indexes . You can store results in a lookup if you want but what is the use case to store it ?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 23:02:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406379#M117476</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-04-12T23:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406380#M117477</link>
      <description>&lt;P&gt;Wanted to check out the data which we are sending and which is been received as well&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 23:13:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406380#M117477</guid>
      <dc:creator>akarunkumar321</dc:creator>
      <dc:date>2019-04-12T23:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for values not present in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406381#M117478</link>
      <description>&lt;P&gt;See my answers here for background:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/567851/how-can-i-compare-mvfields-and-get-a-diff.html"&gt;https://answers.splunk.com/answers/567851/how-can-i-compare-mvfields-and-get-a-diff.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/734599/how-to-compare-the-same-search-from-the-previous-d.html"&gt;https://answers.splunk.com/answers/734599/how-to-compare-the-same-search-from-the-previous-d.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Start with this to create 2 fields with your data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=YouShouldAlwaysSpecifyAnIndex AND (source=service1.log  OR source=service2.log) earliest=-4h latest=now()
| rex field=_raw "trackingId\":\s\"(?&amp;lt;trackingId&amp;gt;[\w-]+)\"" 
| eval ProducerTrackingID = if(source=="service1.log, trackingId, null())
| eval ConsumerTrackingID = if(source=="service1.log, null() trackingId)
| stats values(*TrackingID) AS *TrackingID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For run anywhere, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval ProducerTrackingID="123 456 789", ConsumerTrackingID="456 789" 
| makemv ProducerTrackingID 
| makemv ConsumerTrackingID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then you can EITHER do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| streamstats count AS _serial 
| multireport 
    [| mvexpand ProducerTrackingID
    | where ConsumerTrackingID!=ProducerTrackingID
    | rename ProducerTrackingID AS ProducerTrackingID_only] 
    [| mvexpand ConsumerTrackingID
    | where ConsumerTrackingID!=ProducerTrackingID
    | rename ConsumerTrackingID AS ConsumerTrackingID_only] 
| stats values(*) AS * BY _serial
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| nomv ConsumerTrackingID
| nomv ProducerTrackingID
| rex field=ConsumerTrackingID mode=sed "s/[\r\n\s]+/;/g"
| rex field=ProducerTrackingID mode=sed "s/[\r\n\s]+/;/g"
| eval setdiff = split(replace(replace(replace(replace(mvjoin(mvsort(mvappend(split(replace(ConsumerTrackingID, "(;|$)", "#1;"), ";"), split(replace(ProducerTrackingID, "(;|$)", "#0;"), ";"))), ";"), ";(\w+)#0\;\1#1", ""), ";\w+#1", ""), "#0", ""), ";(?!\w)|^;", ""), ";")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Apr 2019 22:16:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-values-not-present-in-the-lookup-table/m-p/406381#M117478</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-04-15T22:16:40Z</dc:date>
    </item>
  </channel>
</rss>

