<?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 How to compare two searches using a shared variable? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-searches-using-a-shared-variable/m-p/633219#M219973</link>
    <description>&lt;P&gt;I am trying to make 2 searches using the same index and source.&lt;/P&gt;
&lt;P&gt;The first search is looking for all entries with "message received" and the "Message Id". The second search is looking for the "Message Id" and "Message Type".&amp;nbsp; I am trying to find the number of messages received for a specific message type.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;(index = exampleindex source = examplesource ("message received" AND "MessageId")&amp;nbsp; &lt;BR /&gt;| rex field=_raw "MessageId:(?&amp;lt;messageId1&amp;gt;[\S]+)\s.*"&amp;nbsp;&lt;BR /&gt;| eval Id1 = messageId1) &lt;BR /&gt;OR&amp;nbsp;(index = exampleindex source = examplesource ("MessageType" AND "MessageId")&amp;nbsp; &lt;BR /&gt;| rex field=_raw "MessageId:(?&amp;lt;messageId2&amp;gt;[\S]+)\s.*"&amp;nbsp; &lt;BR /&gt;| eval Id2 = messageId2)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I want to compare the 2 searches and count how many Ids in the 1st search appear in the 2nd search&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Mar 2023 19:36:44 GMT</pubDate>
    <dc:creator>ckutach</dc:creator>
    <dc:date>2023-03-03T19:36:44Z</dc:date>
    <item>
      <title>How to compare two searches using a shared variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-searches-using-a-shared-variable/m-p/633219#M219973</link>
      <description>&lt;P&gt;I am trying to make 2 searches using the same index and source.&lt;/P&gt;
&lt;P&gt;The first search is looking for all entries with "message received" and the "Message Id". The second search is looking for the "Message Id" and "Message Type".&amp;nbsp; I am trying to find the number of messages received for a specific message type.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;(index = exampleindex source = examplesource ("message received" AND "MessageId")&amp;nbsp; &lt;BR /&gt;| rex field=_raw "MessageId:(?&amp;lt;messageId1&amp;gt;[\S]+)\s.*"&amp;nbsp;&lt;BR /&gt;| eval Id1 = messageId1) &lt;BR /&gt;OR&amp;nbsp;(index = exampleindex source = examplesource ("MessageType" AND "MessageId")&amp;nbsp; &lt;BR /&gt;| rex field=_raw "MessageId:(?&amp;lt;messageId2&amp;gt;[\S]+)\s.*"&amp;nbsp; &lt;BR /&gt;| eval Id2 = messageId2)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I want to compare the 2 searches and count how many Ids in the 1st search appear in the 2nd search&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 19:36:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-searches-using-a-shared-variable/m-p/633219#M219973</guid>
      <dc:creator>ckutach</dc:creator>
      <dc:date>2023-03-03T19:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing 2 searches using a shared variable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-searches-using-a-shared-variable/m-p/633229#M219978</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;OR&lt;/FONT&gt; operator works within certain commands, but cannot be used to combine commands.&lt;/P&gt;&lt;P&gt;Use &lt;FONT face="courier new,courier"&gt;OR&lt;/FONT&gt; within the base search to fetch events with the desired data then group them by the shared field.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index = exampleindex source = examplesource (("message received" AND "MessageId") OR ("MessageType" AND "MessageId"))
| rex field=_raw "MessageId:(?&amp;lt;messageId&amp;gt;[\S]+)" 
``` Combine events based on shared messageId values ```
| stats values(*) as * by messageId
``` Discard events without a MessageType ```
| where isnotnull(MessageType)
| stats count by MessageType&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 19:21:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-two-searches-using-a-shared-variable/m-p/633229#M219978</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-03-03T19:21:44Z</dc:date>
    </item>
  </channel>
</rss>

