<?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: Why am I getting different results for &amp;quot;stats count&amp;quot; and &amp;quot;tstats count&amp;quot;? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277599#M83718</link>
    <description>&lt;P&gt;Hi woodcock&lt;BR /&gt;
thanks,&lt;/P&gt;

&lt;P&gt;Evan after changing the span still total number of events are not matching&lt;/P&gt;</description>
    <pubDate>Mon, 14 Dec 2015 06:59:55 GMT</pubDate>
    <dc:creator>thippeshaj</dc:creator>
    <dc:date>2015-12-14T06:59:55Z</dc:date>
    <item>
      <title>Why am I getting different results for "stats count" and "tstats count"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277595#M83714</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I'm getting a different values for &lt;CODE&gt;stats count&lt;/CODE&gt; and &lt;CODE&gt;tstats count&lt;/CODE&gt;.&lt;BR /&gt;
Sometimes the data will fix itself after a few days, but not always. I can’t use the data displayed on the dashboard AS is, reason being it’s not reliable, unless I manually do a reconciliation, and if it doesn’t tally, there is pretty much nothing I can do to get the correct data except to wait for a few more days and check again.&lt;/P&gt;

&lt;P&gt;Is there anything that I need to correct ??&lt;BR /&gt;
please help me.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2015 05:57:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277595#M83714</guid>
      <dc:creator>thippeshaj</dc:creator>
      <dc:date>2015-12-11T05:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting different results for "stats count" and "tstats count"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277596#M83715</link>
      <description>&lt;P&gt;What are your search strings?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2015 06:42:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277596#M83715</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-12-11T06:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting different results for "stats count" and "tstats count"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277597#M83716</link>
      <description>&lt;P&gt;Normal Statistic&lt;BR /&gt;
Query : host=xyz sourcetype=abcd | timechart span=1s count &lt;/P&gt;

&lt;P&gt;Tstats&lt;BR /&gt;
Query : | tstats count as "count" WHERE index=main sourcetype=abcd host=xyz by _time span=1s&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2015 11:53:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277597#M83716</guid>
      <dc:creator>thippeshaj</dc:creator>
      <dc:date>2015-12-11T11:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting different results for "stats count" and "tstats count"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277598#M83717</link>
      <description>&lt;P&gt;The problem is that Splunk has bucketed your data in spans bigger than the &lt;CODE&gt;1s&lt;/CODE&gt; value that you have specified in your &lt;CODE&gt;span&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;When I do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count WHERE index=_internal sourcetype=splunkd host="MyHost" BY _time | delta _time AS tstatsBucketSpanSecs | stats values(tstatsBucketSpanSecs)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then I get this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;values(tstatsBucketSpanSecs)
60
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This means that I must not specify a value for &lt;CODE&gt;span&lt;/CODE&gt; that is smaller than the size that you find splunk is bucketing for your data or it will not work correctly.&lt;BR /&gt;
So try changing your span to fit what it is doing and I suspect that it will work the same for both.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Dec 2015 04:52:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277598#M83717</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-12-12T04:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting different results for "stats count" and "tstats count"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277599#M83718</link>
      <description>&lt;P&gt;Hi woodcock&lt;BR /&gt;
thanks,&lt;/P&gt;

&lt;P&gt;Evan after changing the span still total number of events are not matching&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2015 06:59:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277599#M83718</guid>
      <dc:creator>thippeshaj</dc:creator>
      <dc:date>2015-12-14T06:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting different results for "stats count" and "tstats count"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277600#M83719</link>
      <description>&lt;P&gt;&lt;CODE&gt;tstats&lt;/CODE&gt; can support spans of &lt;CODE&gt;1s&lt;/CODE&gt; as seen in the picture. This was generated from the run-anywhere search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal |timechart span=1s count as time_count | join _time type=left [ | tstats count as tstats_count WHERE index=_internal  BY _time span=1s ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/897i054D03210DA685CA/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;The problem is probably stemming from the tokenization of your data. According to the docs (&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.1/SearchReference/Tstats"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.1/SearchReference/Tstats&lt;/A&gt; &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;You might see a count mismatch in the events retrieved when searching tsidx files. This is because it is not possible to distinguish between indexed field tokens and raw tokens in tsidx files. On the other hand, it is more explicit to run tstats on accelerated datamodels or from a tscollect, where only the fields and values are stored and not the raw tokens. 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Therefore, the counts might not always be the same. I'm not 100% sure on how to solve this yet, but are you using &lt;CODE&gt;tscollect&lt;/CODE&gt; or an accelerated datamodel? Those two will return the correct fields, at the cost of pre-processing via &lt;CODE&gt;tscollect&lt;/CODE&gt; or the cost of datamodel acceleration.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2015 12:44:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277600#M83719</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2015-12-14T12:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting different results for "stats count" and "tstats count"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277601#M83720</link>
      <description>&lt;P&gt;Out of curiosity, do you have multiple indexes? I notice your tstats query has index=main, but your normal query does not.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2015 13:51:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277601#M83720</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2015-12-14T13:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting different results for "stats count" and "tstats count"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277602#M83721</link>
      <description>&lt;P&gt;Run these two:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main host=xyz sourcetype=abcd | timechart span=1s count
| tstats count WHERE index=main host=xyz sourcetype=abcd  by _time span=1s prestats=t | timechart span=1s count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Two changes: I've added &lt;CODE&gt;index=main&lt;/CODE&gt; to the first search, and &lt;CODE&gt;prestats=t | timechart ...&lt;/CODE&gt; to the second. The index makes sure you're really using the same input data for both searches. The prestats/timechart makes sure you're producing the same type of output - for example, with empty buckets filled.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2015 17:47:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277602#M83721</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-12-14T17:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting different results for "stats count" and "tstats count"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277603#M83722</link>
      <description>&lt;P&gt;Hi @thippeshaj&lt;/P&gt;

&lt;P&gt;I noticed you upvoted this answer, but didn't click "Accept", so I accepted it for you for now, but can you confirm if this actually did solve your question? Did you check the possible default searched index issue suggested by @acharlieh or  run the test searches suggested by @martin_mueller in the comments under your question? Please comment with follow-up so other users are aware.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2015 19:20:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277603#M83722</guid>
      <dc:creator>ppablo</dc:creator>
      <dc:date>2015-12-15T19:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting different results for "stats count" and "tstats count"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277604#M83723</link>
      <description>&lt;P&gt;Yes achrlieh we have multiple indexes&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 06:27:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277604#M83723</guid>
      <dc:creator>thippeshaj</dc:creator>
      <dc:date>2015-12-16T06:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I getting different results for "stats count" and "tstats count"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277605#M83724</link>
      <description>&lt;P&gt;@martin_mueller&lt;BR /&gt;
I tried but still got the different count....&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 06:30:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-getting-different-results-for-quot-stats-count-quot-and/m-p/277605#M83724</guid>
      <dc:creator>thippeshaj</dc:creator>
      <dc:date>2015-12-16T06:30:32Z</dc:date>
    </item>
  </channel>
</rss>

