<?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: Comparing results of subsearch and main search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Comparing-results-of-subsearch-and-main-search/m-p/173396#M49716</link>
    <description>&lt;P&gt;First of all, do not use subsearches if you can avoid it; this should work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal earliest=-60m@m source=*metrics.log group=queue | stats count As NumByHost count(eval(match(_raw,"%blocked%"))) AS NumBlockedByHost by host | where NumByHost=NumBlockedByHost
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 12 May 2015 19:33:10 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2015-05-12T19:33:10Z</dc:date>
    <item>
      <title>Comparing results of subsearch and main search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-results-of-subsearch-and-main-search/m-p/173394#M49714</link>
      <description>&lt;P&gt;Hi All ,&lt;/P&gt;

&lt;P&gt;My problem statement is to find the blocked queues over 60 minutes consistently which means that there should be no succesfull connection of queues between blocked queues events. So the approach i am following is to compare the number of blocked queues events with the number of events in indexer for last 60 minutes.if they are equal i will be sure that only blocked queues events exist.&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;First i write the following query to count the events per host for blocked queues&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;search index=_internal earliest=-60m@m source=*metrics.log group=queue "blocked" | stats count AS Number by host &lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Then i need to pass the above calculated hosts value in the mainn search so that only for these host the main search runs&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;index=_internal earliest=-60m@m source=*metrics.log group=queue [ search index=_internal earliest=-60m@m source=*metrics.log group=queue "blocked" | stats count AS Number by host | fields + host ] &lt;/P&gt;

&lt;P&gt;Above part is giving me correct host values&lt;/P&gt;

&lt;P&gt;No comes the comparing part, so i build this query&lt;/P&gt;

&lt;P&gt;index=_internal earliest=-60m@m source=*metrics.log group=queue [ search index=_internal earliest=-60m@m source=*metrics.log group=queue "blocked" | stats count AS Number by host | fields + host ] | stats count as Point by host | append [search index=_internal earliest=-60m@m source=*metrics.log group=queue "blocked" | stats count AS Number by host | fields + Number host ] | table host Number Point&lt;/P&gt;

&lt;P&gt;which gives me output&lt;/P&gt;

&lt;P&gt;host            Number                  Point&lt;BR /&gt;
a                                                      123&lt;BR /&gt;&lt;BR /&gt;
b                                                      147&lt;BR /&gt;
a                        1&lt;BR /&gt;
b                        2&lt;/P&gt;

&lt;P&gt;Output is expected as i am running the stats earlier also i the main query but i cannot figure out, how to compare  Number and Point count's. Also please help with the usage of "If" command since if the result matches i need to print the queue name along with host.&lt;/P&gt;

&lt;P&gt;Please help !!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:45:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-results-of-subsearch-and-main-search/m-p/173394#M49714</guid>
      <dc:creator>lohit</dc:creator>
      <dc:date>2020-09-28T19:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing results of subsearch and main search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-results-of-subsearch-and-main-search/m-p/173395#M49715</link>
      <description>&lt;P&gt;just to be sure about the output it is coming like this&lt;/P&gt;

&lt;P&gt;host    Number    Point&lt;BR /&gt;
a           &amp;lt;Nothing&amp;gt;  123&lt;BR /&gt;
b          &amp;lt;Nothing&amp;gt;    146&lt;BR /&gt;
a                  1             &amp;lt;Nothing&amp;gt;&lt;BR /&gt;
b                  2              &amp;lt;Nothing&amp;gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2015 04:11:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-results-of-subsearch-and-main-search/m-p/173395#M49715</guid>
      <dc:creator>lohit</dc:creator>
      <dc:date>2015-05-07T04:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing results of subsearch and main search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-results-of-subsearch-and-main-search/m-p/173396#M49716</link>
      <description>&lt;P&gt;First of all, do not use subsearches if you can avoid it; this should work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal earliest=-60m@m source=*metrics.log group=queue | stats count As NumByHost count(eval(match(_raw,"%blocked%"))) AS NumBlockedByHost by host | where NumByHost=NumBlockedByHost
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 May 2015 19:33:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-results-of-subsearch-and-main-search/m-p/173396#M49716</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-05-12T19:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing results of subsearch and main search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-results-of-subsearch-and-main-search/m-p/173397#M49717</link>
      <description>&lt;P&gt;Did the answer above work for your query? &lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 18:28:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-results-of-subsearch-and-main-search/m-p/173397#M49717</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-04-11T18:28:53Z</dc:date>
    </item>
  </channel>
</rss>

