<?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: Diff between 2 tables in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573645#M199908</link>
    <description>&lt;P&gt;Thanks for the reply PickleRick. I do have a field that can help me differentiate both sets (something like "System1" and "System2").&amp;nbsp; Both datasets are pretty huge, so was trying to see if there was better way than append suggestion in previous post.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Nov 2021 16:05:27 GMT</pubDate>
    <dc:creator>sfbayeng</dc:creator>
    <dc:date>2021-11-04T16:05:27Z</dc:date>
    <item>
      <title>Diff between 2 tables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573556#M199871</link>
      <description>&lt;P&gt;I have splunk queries that generates 2 different tables having similar fields (METHOD, URI, COUNT). I wanted to do a diff between them based on URI and also the count.&lt;BR /&gt;Eg:&lt;/P&gt;&lt;P&gt;tableA&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;METHOD&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;URI&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;COUNT&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;GET&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;1/0/foo&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;PUT&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;1/0/bar&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;&amp;nbsp;11&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;tableB&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;METHOD&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;URI&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;COUNT&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;GET&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;1/0/foo&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;PUT&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;1/0/bar&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;PUT&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;1/0/buzz&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;1&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Is there a way to do difference between 2 tables based on METHOD+URI and COUNT? Result should be something like&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;METHOD&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;URI&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;COUNT&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;GET&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;1/0/foo&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;1&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;PUT&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;1/0/buzz&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;1&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 03 Nov 2021 23:19:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573556#M199871</guid>
      <dc:creator>sfbayeng</dc:creator>
      <dc:date>2021-11-03T23:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Diff between 2 tables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573571#M199878</link>
      <description>&lt;P&gt;The diff part should be ralitively easy. You just count values from one set into one field, from the other set into other one and do your substraction. It can be more tricky to generate a common result set without using append. Is there a single field that differentiates your both sets (like, first search is from one index and the other is from another; or source; or whatever)?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 05:11:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573571#M199878</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-11-04T05:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: Diff between 2 tables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573572#M199879</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/240422"&gt;@sfbayeng&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please try this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;YOUR_FIRST_TABLE_SEARCH
| append [
YOUR_SECOND_TABLE_SEARCH ]
| stats max(COUNT) as mx min(COUNT) as mn list(COUNT) as COUNT by URI METHOD
| eval COUNT=if(mvcount(COUNT)==1,COUNT, mx-mn)
| where COUNT&amp;gt;0
| table METHOD URI COUNT&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Sample Search :&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval _raw="METHOD	URI	COUNT
GET	1/0/foo	3
PUT	1/0/bar	 11" | multikv forceheader=1
| append [
| makeresults | eval _raw="METHOD	URI	COUNT
GET	1/0/foo	2
PUT	1/0/bar	11
PUT	1/0/buzz	1" | multikv forceheader=1 ]
| stats max(COUNT) as mx min(COUNT) as mn list(COUNT) as COUNT by URI METHOD
| eval COUNT=if(mvcount(COUNT)==1,COUNT, mx-mn)
| where COUNT&amp;gt;0
| table METHOD URI COUNT&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this will help you.&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;▄︻̷̿┻̿═━一 &amp;nbsp; &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 05:19:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573572#M199879</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-11-04T05:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: Diff between 2 tables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573591#M199887</link>
      <description>&lt;P&gt;A bit overcomplicated &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If you want to use append (which might not be the best approach if there are many results), you can simply&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;first_search&amp;gt;
| eval searchno=1
| append [
 &amp;lt;second_search&amp;gt;
 | eval searchno=2 ]
| stats count(eval(searchno=1)) as s1count
   count(eval(searchno=2)) as s2count
   by METHOD URI
| eval diff=s1count-s2count&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 04 Nov 2021 08:28:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573591#M199887</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-11-04T08:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: Diff between 2 tables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573644#M199907</link>
      <description>&lt;P&gt;Thanks for the reply KV. In my case, the dataset is huge, so append might be bit problematic.&amp;nbsp; I'll try this approach out and let you know.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: This approach was bit slow, so went with other solution mentioned in thread. Thanks a lot&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2021 00:08:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573644#M199907</guid>
      <dc:creator>sfbayeng</dc:creator>
      <dc:date>2021-11-05T00:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Diff between 2 tables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573645#M199908</link>
      <description>&lt;P&gt;Thanks for the reply PickleRick. I do have a field that can help me differentiate both sets (something like "System1" and "System2").&amp;nbsp; Both datasets are pretty huge, so was trying to see if there was better way than append suggestion in previous post.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 16:05:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573645#M199908</guid>
      <dc:creator>sfbayeng</dc:creator>
      <dc:date>2021-11-04T16:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Diff between 2 tables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573664#M199920</link>
      <description>&lt;P&gt;Thought so &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If your result sets are sizeable, you shouldn't indeed use append.&lt;/P&gt;&lt;P&gt;The proper way to go would be to combine conditions from both searches into one (with an OR operator) and then conditionally set an indicator field to show if it's an event from the first search or the second one. Something like&lt;/P&gt;&lt;PRE&gt;(&amp;lt;your_first_search_conditions&amp;gt;) OR (&amp;lt;your_second_search_conditions&amp;gt;)&lt;BR /&gt;| eval searchno=if(some_field=something,1,2)&lt;BR /&gt;| stats count(eval(searchno=1)) as s1count&lt;BR /&gt;  count(eval(searchno=2)) as s2count&lt;BR /&gt;  by METHOD URI&lt;BR /&gt;| eval diff=s2count-s1coun&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Nov 2021 19:10:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573664#M199920</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-11-04T19:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Diff between 2 tables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573720#M199941</link>
      <description>&lt;P&gt;Thanks a lot..it works with your approach&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2021 00:07:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Diff-between-2-tables/m-p/573720#M199941</guid>
      <dc:creator>sfbayeng</dc:creator>
      <dc:date>2021-11-05T00:07:10Z</dc:date>
    </item>
  </channel>
</rss>

