<?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 vs timechart in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321955#M96181</link>
    <description>&lt;P&gt;In order to show a trend at a granularity of an hour, you should probably be using a smaller span.  &lt;/P&gt;

&lt;P&gt;This counts 10 pulses per hour, and then calculates how many faults there had been for the prior 60 minutes at the end of that pulse.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index= sourcetype=* ServiceName="*" OperationName="*" Fault=true FaultCode="XXXXX" 
| bin _time span=6m
| stats count as pulsecount by _time
| streamstats window=10 sum(pulsecount) as hourcount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This counts 10 pulses per hour, and then calculates that hour's simple moving average of the number of faults in each 6-minute pulse.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index= sourcetype=* ServiceName="*" OperationName="*" Fault=true FaultCode="XXXXX" 
| bin _time span=6m
| stats count as pulsecount by _time
| trendline sma10(pulsecount) as sma10 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For both of the above, you would start with earliest=-3h or so, in order to have an established trend at the -2h point, and then put a where clause at the end to eliminate records that were too old to consider.  &lt;/P&gt;</description>
    <pubDate>Fri, 07 Apr 2017 22:36:24 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-04-07T22:36:24Z</dc:date>
    <item>
      <title>stats vs timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321949#M96175</link>
      <description>&lt;P&gt;i am getting two different outputs while using &lt;CODE&gt;stats count( 1hr time interval)&lt;/CODE&gt;  and &lt;CODE&gt;timechart count span=1h&lt;/CODE&gt;.  I was using timechart to showcase the trend for the  previous hour too.&lt;/P&gt;

&lt;P&gt;Highly appreciate your comments&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 19:58:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321949#M96175</guid>
      <dc:creator>apillai01</dc:creator>
      <dc:date>2017-04-07T19:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: stats vs timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321950#M96176</link>
      <description>&lt;P&gt;@apillai01 - Could you provide more information as to what your intended result should be? It is not clear from your question. Please leave a comment below.&lt;/P&gt;

&lt;P&gt;In general, your question has a greater chance of being answered by experts in the Answers community when when you provide as much information and context as possible. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 20:18:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321950#M96176</guid>
      <dc:creator>aaraneta_splunk</dc:creator>
      <dc:date>2017-04-07T20:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: stats vs timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321951#M96177</link>
      <description>&lt;P&gt;i am trying to create a dashboard  with two views&lt;BR /&gt;
1.  Count of  Faults for the current hour &lt;BR /&gt;
2.  Fault trend current vs previous hour&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 20:24:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321951#M96177</guid>
      <dc:creator>apillai01</dc:creator>
      <dc:date>2017-04-07T20:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: stats vs timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321952#M96178</link>
      <description>&lt;P&gt;What is the current search (at least provide some sudo code) and the time range used in both the searches? My guess is the timechart's bucket is different (it takes full hour) than what stats is considering and it's because of time range used.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 20:42:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321952#M96178</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-04-07T20:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: stats vs timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321953#M96179</link>
      <description>&lt;OL&gt;
&lt;LI&gt;current search code: index =  sourcetype = * ServiceName="&lt;EM&gt;"OperationName="&lt;/EM&gt;" Fault=true FaultCode="XXXXX"|stats count as Total&lt;/LI&gt;
&lt;LI&gt;Trend( compare current hr vs previous hr): 
index =  sourcetype = * ServiceName="&lt;EM&gt;"OperationName="&lt;/EM&gt;" Fault=true FaultCode="XXXXX"|timechart count span=1h&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;both the case i am using time range as 1 hour&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 20:52:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321953#M96179</guid>
      <dc:creator>apillai01</dc:creator>
      <dc:date>2017-04-07T20:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: stats vs timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321954#M96180</link>
      <description>&lt;P&gt;For Trend, shouldn't you be using time range as 2 hours, one for current hour and one for last hour?  Also, when you say current hour, if now is 2:30PM, you want to count 2:00 to 2:30 OR 1:30 to 2:30?&lt;/P&gt;

&lt;P&gt;I'm guessing this is what you want but check,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = sourcetype = ServiceName=""OperationName="*" Fault=true FaultCode="XXXXX" earliest=@h |stats count as Total

index = sourcetype = ServiceName=""OperationName="*" Fault=true FaultCode="XXXXX" earliest=-1h@h |timechart count span=1h
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Apr 2017 20:58:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321954#M96180</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-04-07T20:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: stats vs timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321955#M96181</link>
      <description>&lt;P&gt;In order to show a trend at a granularity of an hour, you should probably be using a smaller span.  &lt;/P&gt;

&lt;P&gt;This counts 10 pulses per hour, and then calculates how many faults there had been for the prior 60 minutes at the end of that pulse.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index= sourcetype=* ServiceName="*" OperationName="*" Fault=true FaultCode="XXXXX" 
| bin _time span=6m
| stats count as pulsecount by _time
| streamstats window=10 sum(pulsecount) as hourcount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This counts 10 pulses per hour, and then calculates that hour's simple moving average of the number of faults in each 6-minute pulse.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index= sourcetype=* ServiceName="*" OperationName="*" Fault=true FaultCode="XXXXX" 
| bin _time span=6m
| stats count as pulsecount by _time
| trendline sma10(pulsecount) as sma10 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For both of the above, you would start with earliest=-3h or so, in order to have an established trend at the -2h point, and then put a where clause at the end to eliminate records that were too old to consider.  &lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 22:36:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321955#M96181</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-04-07T22:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: stats vs timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321956#M96182</link>
      <description>&lt;P&gt;The timepicker probably says &lt;CODE&gt;Last hour&lt;/CODE&gt; which is &lt;CODE&gt;-60m@m&lt;/CODE&gt; but time chart does not use a &lt;CODE&gt;snap-to&lt;/CODE&gt; of &lt;CODE&gt;@m&lt;/CODE&gt;; it uses a &lt;CODE&gt;snap-to&lt;/CODE&gt; of &lt;CODE&gt;@h&lt;/CODE&gt;.  To make them match, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your search here earliest=-2h@h latest=-1h@h | stats count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And compare that to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your search here earliest=-2h@h latest=-1h@h | timechar span=1h count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Apr 2017 23:28:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321956#M96182</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-04-07T23:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: stats vs timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321957#M96183</link>
      <description>&lt;P&gt;Thanks, it worked!&lt;/P&gt;</description>
      <pubDate>Sat, 08 Apr 2017 01:52:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321957#M96183</guid>
      <dc:creator>apillai01</dc:creator>
      <dc:date>2017-04-08T01:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: stats vs timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321958#M96184</link>
      <description>&lt;P&gt;Also check out the difference of this with &lt;CODE&gt;bin&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your search here earliest=-3h@h latest=-1h@h | bin _time span=1h | stats count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 09 Apr 2017 14:03:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-vs-timechart/m-p/321958#M96184</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-04-09T14:03:39Z</dc:date>
    </item>
  </channel>
</rss>

