<?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 compare the results of 2 searches? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-results-of-2-searches/m-p/655093#M226301</link>
    <description>&lt;P&gt;You can perform a set operation on the two searches as illustrated. &amp;nbsp;But a far more efficient method is to perform just one search and use &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/MultivalueEvalFunctions#mvmap.28.26lt.3Bmv.26gt.3B.2C.26lt.3Bexpression.26gt.3B.29" target="_blank" rel="noopener"&gt;mvmap&lt;/A&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=sampleindex source=samplesource (SUCCESS OR FAILURE)
| rex field=data max_match=0 "\"SUCCESS\" \"ID:\s*(?&amp;lt;success&amp;gt;\d+)"
| rex field=data max_match=0 "\"FAILURE\" \"ID:\s*(?&amp;lt;failure&amp;gt;\d+)"
| eval failed = mvmap(failure, if(failure != success, failure, null()))&lt;/LI-CODE&gt;&lt;P&gt;(In SPL, equality test of a scalar and a vector iterates over the vector.) &amp;nbsp;The field failed now contains all the failure IDs that is not found in success.&lt;/P&gt;</description>
    <pubDate>Mon, 21 Aug 2023 22:37:55 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2023-08-21T22:37:55Z</dc:date>
    <item>
      <title>How to compare the results of 2 searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-results-of-2-searches/m-p/655071#M226297</link>
      <description>&lt;P&gt;I have splunk logs that are of 2 types, successes and failures. They contain 2 things:&lt;/P&gt;
&lt;P&gt;"SUCCESS" "ID: &amp;lt;IDNumber&amp;gt;"&lt;/P&gt;
&lt;P&gt;"FAILURE" "ID: &amp;lt;IDNumber&amp;gt;"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My goal is to find IDs that are identified with failures that are not also identified with a success. So for the data:&lt;/P&gt;
&lt;P&gt;"SUCCESS" "ID: 0000", "FAILURE" "ID: 0000", "SUCCESS" "ID: 1111", "FAILURE" "ID: 2222", "SUCCESS" "ID: 3333", "FAILURE" "ID: 4444"&lt;/P&gt;
&lt;P&gt;the result would be the IDs 2222 and 4444&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My current search is:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=sampleindex source=samplesource "SUCCESS" | rex field=_raw "ID: (?&amp;lt;id1&amp;gt;+)" | join [search index=sampleindex source=samplesource "FAILURE" | rex field=_raw "ID: (?&amp;lt;id2&amp;gt;+)"] | table id1, id2&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I am able to perform each of these searches separately and output the ids, but when I combine them I cannot get the results of either id1 or id2, so I am not able to compare them&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone know how I can structure my search to achieve my final goal?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 20:01:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-results-of-2-searches/m-p/655071#M226297</guid>
      <dc:creator>ckutach</dc:creator>
      <dc:date>2023-08-21T20:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the results of 2 searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-results-of-2-searches/m-p/655093#M226301</link>
      <description>&lt;P&gt;You can perform a set operation on the two searches as illustrated. &amp;nbsp;But a far more efficient method is to perform just one search and use &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/MultivalueEvalFunctions#mvmap.28.26lt.3Bmv.26gt.3B.2C.26lt.3Bexpression.26gt.3B.29" target="_blank" rel="noopener"&gt;mvmap&lt;/A&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=sampleindex source=samplesource (SUCCESS OR FAILURE)
| rex field=data max_match=0 "\"SUCCESS\" \"ID:\s*(?&amp;lt;success&amp;gt;\d+)"
| rex field=data max_match=0 "\"FAILURE\" \"ID:\s*(?&amp;lt;failure&amp;gt;\d+)"
| eval failed = mvmap(failure, if(failure != success, failure, null()))&lt;/LI-CODE&gt;&lt;P&gt;(In SPL, equality test of a scalar and a vector iterates over the vector.) &amp;nbsp;The field failed now contains all the failure IDs that is not found in success.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 22:37:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-results-of-2-searches/m-p/655093#M226301</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-08-21T22:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare the results of 2 searches?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-results-of-2-searches/m-p/655099#M226305</link>
      <description>&lt;P&gt;I am assuming that you will have 2 separate events, one for success and one for failure, so in that case, you'll need a slightly different version of&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;SPL&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=sampleindex source=samplesource (SUCCESS OR FAILURE)
| rex field=data "\"(?&amp;lt;status&amp;gt;SUCCESS)\" \"ID:\s*(?&amp;lt;id&amp;gt;\d+)"
| rex field=data "\"(?&amp;lt;status&amp;gt;FAILURE)\" \"ID:\s*(?&amp;lt;id&amp;gt;\d+)"
| stats values(status) as status by id
| where mvcount(status)=1 AND status="FAILURE"&lt;/LI-CODE&gt;&lt;P&gt;so the stats command combines all status values for the same id and then the where clause filters out only those ids where the status is FAILURE only&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 00:42:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-results-of-2-searches/m-p/655099#M226305</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-08-22T00:42:05Z</dc:date>
    </item>
  </channel>
</rss>

