<?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: Compare two search results and list difference and matches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607650#M211292</link>
    <description>&lt;P&gt;You could try the mvfilter command or use&amp;nbsp;&lt;BR /&gt;| where 'paths{}' !="*.cpp"&lt;BR /&gt;after the mvexpand&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 31 Jul 2022 11:31:01 GMT</pubDate>
    <dc:creator>martinpu</dc:creator>
    <dc:date>2022-07-31T11:31:01Z</dc:date>
    <item>
      <title>How to compare two search results and list difference and matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607622#M211277</link>
      <description>&lt;P&gt;Hi guys im new to Splunk,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Im trying to write a query to compare two search results and shows the differences and the matches, both search results are coming from the same index.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to have something like this, where&amp;nbsp;{path-values}&amp;nbsp; hold the paths values and&amp;nbsp;{countpath} holds the count.&lt;/P&gt;
&lt;P&gt;Build-type&amp;nbsp; &amp;nbsp;|&amp;nbsp; paths-count | matches-values&amp;nbsp; &amp;nbsp; | diff-values&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| matches-count | diff-count|&amp;nbsp;&lt;/P&gt;
&lt;P&gt;gradle&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 20K&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | {path-values}&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp;{path-values}&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | {countpath}&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| {countpath}&amp;nbsp;&lt;/P&gt;
&lt;P&gt;bazel&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 10K&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | {path-values}&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp;{path-values}&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; | {countpath}&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| {countpath}&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my index is based on this json, where total event is a 30k (number of json posted to splunk)&lt;/P&gt;
&lt;P&gt;{"source":"build","sourcetype":"json","event":{"type":"bazel","paths":["test3"]}}&lt;/P&gt;
&lt;P&gt;my current query looks like:&lt;/P&gt;
&lt;P&gt;index="build" type="bazel"&lt;BR /&gt;| stats values(paths{}) as paths | stats count(eval(paths)) AS totalbazelpaths&lt;BR /&gt;| mvexpand totalbazelpaths&lt;BR /&gt;| eval eventFound = 0&lt;BR /&gt;| join type=left run_id paths&lt;BR /&gt;[ index="build" type="gradle"&lt;BR /&gt;| stats values(paths{}) as paths | stats count(eval(paths)) AS totalgradlepaths&lt;BR /&gt;| mvexpand totalgradlepaths&lt;BR /&gt;| eval eventFound=1]&lt;BR /&gt;| eval percentage = round(totalbazelpaths/totalgradlepaths, 10)&lt;BR /&gt;| table totalgradlepaths totalbazelpaths percentage&lt;/P&gt;
&lt;P&gt;any help how to achieve this?&amp;nbsp;@&lt;SPAN&gt;yuanliu&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jul 2022 22:21:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607622#M211277</guid>
      <dc:creator>ikenahim7</dc:creator>
      <dc:date>2022-07-30T22:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two search results and list difference and matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607625#M211280</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;index="build" type="bazel" OR type="gradle"&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;| stats values(paths{}) as paths_values, dc(paths{}))&amp;nbsp; as distinct_paths_count c(paths{}))&amp;nbsp; as count_paths&amp;nbsp; by type&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;Not sure what you mean by matches.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jul 2022 21:45:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607625#M211280</guid>
      <dc:creator>martinpu</dc:creator>
      <dc:date>2022-07-30T21:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two search results and list difference and matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607626#M211281</link>
      <description>&lt;P&gt;I meant by matches, paths that are common for both type gradle and bazel.&lt;/P&gt;&lt;P&gt;so the idea is to show number of paths for each type (bazel and gradle)&lt;/P&gt;&lt;P&gt;show the number of common paths between bazel and gradle &amp;nbsp;and&amp;nbsp;&lt;SPAN&gt;show the actual paths value that are common&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;shows the number of paths that aren’t common &amp;nbsp;and&amp;nbsp;&lt;SPAN&gt;show the actual paths thats aren't common.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jul 2022 21:59:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607626#M211281</guid>
      <dc:creator>ikenahim7</dc:creator>
      <dc:date>2022-07-30T21:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two search results and list difference and matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607631#M211285</link>
      <description>&lt;P&gt;Not sure if it is useful to show every column as illustrated, but it's certainly doable. &amp;nbsp;Sample code could be&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="build" (type="bazel" OR type="gradle")
| mvexpand paths{}
| eventstats dc(type) as typecount values(type) as types by paths{}
| eval matches_values = if(typecount&amp;gt;1, 'paths{}', null()), diff_values = if(typecount&amp;gt;1, null(), 'paths{}')
| stats dc(eval('paths{}')) as paths-count values(*_values) as *_values dc(*_values) as *-count by type&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using simulated data based on your example, you can get&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;_raw&lt;/TD&gt;&lt;TD&gt;type&lt;/TD&gt;&lt;TD&gt;paths-count&lt;/TD&gt;&lt;TD&gt;diff_values&lt;/TD&gt;&lt;TD&gt;matches_values&lt;/TD&gt;&lt;TD&gt;diff-count&lt;/TD&gt;&lt;TD&gt;matches-count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;{"source":"build","sourcetype":"json","event":{"type":"bazel","paths":["test1", "test3"]}}&lt;/TD&gt;&lt;TD&gt;bazel&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;test1&lt;/TD&gt;&lt;TD&gt;test3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;{"source":"build","sourcetype":"json","event":{"type":"gradle","paths":["test2", "test3"]}}&lt;/TD&gt;&lt;TD&gt;gradle&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;test2&lt;/TD&gt;&lt;TD&gt;test3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Jul 2022 04:09:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607631#M211285</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-07-31T04:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two search results and list difference and matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607642#M211290</link>
      <description>&lt;P&gt;The query works as expected thanks a lot.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I want to extend the query to ignore some paths based on a string value , how i can achieve that ?&lt;/P&gt;&lt;P&gt;assuming I have:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;{"source":"build","sourcetype":"json","event":{"type":"bazel","paths":["test1.cpp", "test3.c"]}}&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;{"source":"build","sourcetype":"json","event":{"type":"gradle","paths":["test2.cpp", "test3.py"]}}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Comparing this two I want to ignore path with extension&amp;nbsp;".cpp" from being used while comparing Gradle with Bazel ?, so the total account of Gradle path wont count paths with .cpp and also wont be list in diff_values ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Jul 2022 09:51:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607642#M211290</guid>
      <dc:creator>ikenahim7</dc:creator>
      <dc:date>2022-07-31T09:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two search results and list difference and matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607650#M211292</link>
      <description>&lt;P&gt;You could try the mvfilter command or use&amp;nbsp;&lt;BR /&gt;| where 'paths{}' !="*.cpp"&lt;BR /&gt;after the mvexpand&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Jul 2022 11:31:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607650#M211292</guid>
      <dc:creator>martinpu</dc:creator>
      <dc:date>2022-07-31T11:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two search results and list difference and matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607685#M211301</link>
      <description>&lt;P&gt;Small correction:&amp;nbsp;&lt;FONT face="andale mono,times"&gt;search&lt;/FONT&gt; command wildcard doesn't work in &lt;FONT face="andale mono,times"&gt;where&lt;/FONT&gt; command. &amp;nbsp;So, either &lt;FONT face="andale mono,times"&gt;| search paths{} !="*.cpp"&lt;/FONT&gt; or &lt;FONT face="andale mono,times"&gt;| where match('paths{}', "\.cpp$")&lt;/FONT&gt;&amp;nbsp;after &amp;nbsp;mvexpand, e.g.,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="build" (type="bazel" OR type="gradle")
| mvexpand paths{}
| search paths{} != *.cpp
| eventstats dc(type) as typecount values(type) as types by paths{}
| eval matches_values = if(typecount&amp;gt;1, 'paths{}', null()), diff_values = if(typecount&amp;gt;1, null(), 'paths{}')
| stats dc(eval('paths{}')) as paths-count values(*_values) as *_values dc(*_values) as *-count by type&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 01 Aug 2022 01:06:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607685#M211301</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-08-01T01:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two search results and list difference and matches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607698#M211311</link>
      <description>&lt;P&gt;Thanks a lot, query looks as expected &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 06:23:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-search-results-and-list-difference-and/m-p/607698#M211311</guid>
      <dc:creator>ikenahim7</dc:creator>
      <dc:date>2022-08-01T06:23:16Z</dc:date>
    </item>
  </channel>
</rss>

