<?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: stats count not work in sub query? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175257#M50315</link>
    <description>&lt;P&gt;when i use head 20 in sub query they give 20 result, when i use head 20 in main query they give 20 result and when i use head 20 in bot they give 19 result .Result is correct&lt;/P&gt;

&lt;P&gt;index="uk" sourcetype="ukpro2" serviceType=1 message="Received * bytes from IP*"|rename time as time1,message as Request |head 20 | join type="outer" audit[search index="uk" sourcetype="ukpro2" serviceType=1 message="Deleted m_pReceivingSocket"| rename time as time2, message as Responce |head 20]| eval itime=strptime(time1,"%H:%M:%S.%3N") | eval ptime=strptime(time2,"%H:%M:%S.%3N")  | eval TimeDiff=ptime  -itime |where TimeDiff &amp;gt; 0  |table time2 time1 TimeDiff audit Request Responce  |stats avg(TimeDiff) as AVG, max(TimeDiff) as MAX, min(TimeDiff) as Min&lt;/P&gt;</description>
    <pubDate>Fri, 08 May 2015 11:49:34 GMT</pubDate>
    <dc:creator>nitesh218ss</dc:creator>
    <dc:date>2015-05-08T11:49:34Z</dc:date>
    <item>
      <title>stats count not work in sub query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175251#M50309</link>
      <description>&lt;P&gt;I create a query which have sub query i want total number of event on sub query but they  show blank result &lt;/P&gt;

&lt;P&gt;My Query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="uk" sourcetype="ukpro" serviceType=1 message="Received * bytes from IP*" 
| rename time as time1,message as Request 
| join audit [search index="uk" sourcetype="ukpro" serviceType=1 message="Deleted m_pReceivingSocket" 
             | rename time as time2, message as Responce 
             | stats count as req]
| eval itime=strptime(time1,"%H:%M:%S.%3N") 
| eval ptime=strptime(time2,"%H:%M:%S.%3N") 
| eval TimeDiff=ptime  -itime
| table time2 time1 TimeDiff audit Request Responce 
| stats avg(TimeDiff) as AVG, max(TimeDiff) as MAX, min(TimeDiff) as Min,count(Responce)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you see in sub query last i added&lt;BR /&gt;
.....| stats count as req&lt;BR /&gt;
which not counting &lt;BR /&gt;
i use eventstats  but they also not work&lt;/P&gt;

&lt;P&gt;How i count sub query event&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2015 05:00:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175251#M50309</guid>
      <dc:creator>nitesh218ss</dc:creator>
      <dc:date>2015-05-08T05:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: stats count not work in sub query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175252#M50310</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;The first query and subquery should have a field named &lt;STRONG&gt;audit&lt;/STRONG&gt;. Also, there should be some correlation between these searches. Try outer join to see if there is any correlation between the data returned by both the searches.&lt;/P&gt;

&lt;P&gt;Thanks!!&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2015 08:26:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175252#M50310</guid>
      <dc:creator>vganjare</dc:creator>
      <dc:date>2015-05-08T08:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: stats count not work in sub query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175253#M50311</link>
      <description>&lt;P&gt;outer join also not work&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2015 08:33:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175253#M50311</guid>
      <dc:creator>nitesh218ss</dc:creator>
      <dc:date>2015-05-08T08:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: stats count not work in sub query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175254#M50312</link>
      <description>&lt;P&gt;Can you please check if both the searches are returning valid results? Try to limit the result to 10 rows for testing.&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2015 08:41:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175254#M50312</guid>
      <dc:creator>vganjare</dc:creator>
      <dc:date>2015-05-08T08:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: stats count not work in sub query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175255#M50313</link>
      <description>&lt;P&gt;i use head 10 in both query &lt;BR /&gt;
they working fine&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2015 10:00:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175255#M50313</guid>
      <dc:creator>nitesh218ss</dc:creator>
      <dc:date>2015-05-08T10:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: stats count not work in sub query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175256#M50314</link>
      <description>&lt;P&gt;Can you try running the entire query against these 20 results? Ideally, the join should give you some result.&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2015 10:13:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175256#M50314</guid>
      <dc:creator>vganjare</dc:creator>
      <dc:date>2015-05-08T10:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: stats count not work in sub query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175257#M50315</link>
      <description>&lt;P&gt;when i use head 20 in sub query they give 20 result, when i use head 20 in main query they give 20 result and when i use head 20 in bot they give 19 result .Result is correct&lt;/P&gt;

&lt;P&gt;index="uk" sourcetype="ukpro2" serviceType=1 message="Received * bytes from IP*"|rename time as time1,message as Request |head 20 | join type="outer" audit[search index="uk" sourcetype="ukpro2" serviceType=1 message="Deleted m_pReceivingSocket"| rename time as time2, message as Responce |head 20]| eval itime=strptime(time1,"%H:%M:%S.%3N") | eval ptime=strptime(time2,"%H:%M:%S.%3N")  | eval TimeDiff=ptime  -itime |where TimeDiff &amp;gt; 0  |table time2 time1 TimeDiff audit Request Responce  |stats avg(TimeDiff) as AVG, max(TimeDiff) as MAX, min(TimeDiff) as Min&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2015 11:49:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175257#M50315</guid>
      <dc:creator>nitesh218ss</dc:creator>
      <dc:date>2015-05-08T11:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: stats count not work in sub query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175258#M50316</link>
      <description>&lt;P&gt;Can you verify if the result is missing due to subsearch limits? This can be verified from Search Job Inspector.&lt;/P&gt;

&lt;P&gt;Thanks!!&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2015 11:57:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175258#M50316</guid>
      <dc:creator>vganjare</dc:creator>
      <dc:date>2015-05-08T11:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: stats count not work in sub query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175259#M50317</link>
      <description>&lt;P&gt;the result come only is audit no is match in both query&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2015 13:01:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175259#M50317</guid>
      <dc:creator>nitesh218ss</dc:creator>
      <dc:date>2015-05-08T13:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: stats count not work in sub query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175260#M50318</link>
      <description>&lt;P&gt;You don't want the join command here.  I think you want to use append instead. &lt;/P&gt;

&lt;P&gt;The join command by it's nature will take rows from the outer search and match them up with rows from the inner search that have the same value for the joined field (here your field called "audit").  Since your inner search ends in &lt;CODE&gt;stats count as req&lt;/CODE&gt;, it will have no value at all for audit, so that row will be discarded.  &lt;/P&gt;

&lt;P&gt;What you want in this case, if you just want to add the results of your subsearch to the main search results,  is &lt;CODE&gt;append&lt;/CODE&gt; instead of &lt;CODE&gt;join&lt;/CODE&gt;. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="uk" sourcetype="ukpro" serviceType=1 message="Received * bytes from IP*" 
 | rename time as time1,message as Request 
 | append [search index="uk" sourcetype="ukpro" serviceType=1 message="Deleted m_pReceivingSocket" 
              | rename time as time2, message as Responce 
              | stats count as req]
 | eval itime=strptime(time1,"%H:%M:%S.%3N") 
 | eval ptime=strptime(time2,"%H:%M:%S.%3N") 
 | eval TimeDiff=ptime  -itime
 | table time2 time1 TimeDiff audit Request Responce 
 | stats avg(TimeDiff) as AVG, max(TimeDiff) as MAX, min(TimeDiff) as Min,count(Responce)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 May 2015 13:34:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175260#M50318</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2015-05-08T13:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: stats count not work in sub query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175261#M50319</link>
      <description>&lt;P&gt;I use append but they not given correct result&lt;/P&gt;

&lt;P&gt;value of audit are present in both search sub search and main search because audit no is similar for one transaction  that message "Received * bytes from IP*" for start transaction  and message "Deleted m_pReceivingSocket" for end transaction &lt;BR /&gt;
so audit value are present every time if audit value are not equal in both side they not count because of join&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2015 18:06:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175261#M50319</guid>
      <dc:creator>nitesh218ss</dc:creator>
      <dc:date>2015-05-08T18:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: stats count not work in sub query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175262#M50320</link>
      <description>&lt;P&gt;Hi nitesh218ss &lt;BR /&gt;
Try with this xml code&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search index="uk" sourcetype="ukpro" serviceType=1 message="Deleted m_pReceivingSocket"
| rename time as time2, message as Responce
| stats count as req|appendcols[search index="uk" sourcetype="ukpro" serviceType=1 message="Received * bytes from IP*"
| rename time as time1,message as Request]
| eval itime=strptime(time1,"%H:%M:%S.%3N")
| eval ptime=strptime(time2,"%H:%M:%S.%3N")
| eval TimeDiff=ptime -itime
| table time2 time1 TimeDiff audit Request Responce req
| stats avg(TimeDiff) as AVG, max(TimeDiff) as MAX, min(TimeDiff) as Min,count(Responce)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 09 May 2015 09:02:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-count-not-work-in-sub-query/m-p/175262#M50320</guid>
      <dc:creator>chimell</dc:creator>
      <dc:date>2015-05-09T09:02:56Z</dc:date>
    </item>
  </channel>
</rss>

