<?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: Understanding bins and spans in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Understanding-bins-and-spans/m-p/443759#M125869</link>
    <description>&lt;P&gt;look like you are making thing very difficult.&lt;BR /&gt;
Please use the below query. it will work&lt;/P&gt;

&lt;P&gt;index="index" "message: end" &lt;BR /&gt;
           | timechart span=1h count as complete &lt;BR /&gt;
           | appendcols  [ search index="index" "message: end" "status: failed"&lt;BR /&gt;
           | timechart span=1h count as failed ] &lt;BR /&gt;
           | eval percentage=failed*100/complete as "Failed %"&lt;/P&gt;

&lt;P&gt;Please let me know if any issues&lt;/P&gt;</description>
    <pubDate>Tue, 12 Jun 2018 08:54:51 GMT</pubDate>
    <dc:creator>logloganathan</dc:creator>
    <dc:date>2018-06-12T08:54:51Z</dc:date>
    <item>
      <title>Understanding bins and spans</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Understanding-bins-and-spans/m-p/443758#M125868</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
here is a query that is supposed to calculate a % of failed operations over a period of time (A message 'end' is sent with a status that could be 'failed').  Please excuse incorrect or non technical terminology, I'm a very new to this. I am trying to make sure I understand the meaning of bin and span in this particular search.  Does this mean that I'm putting all of my events into chunks by 1 hour (so all events from 11am until noon are in one bucket, all events from noon to 1pm are in the next bucket, etc).  Then I calculate the total number of events per each bucket (count as complete), calculate the total number of events per each bucket where status=failed (eval(status="failed")).  Then for the timechart command, I add up all these totals from each bucket over 1 day and calculate my percentage.  Is that a correct understanding?   Thank you!&lt;/P&gt;

&lt;P&gt;For example, if my data is like this:&lt;BR /&gt;
event 1:&lt;BR /&gt;
timestamp: June 11, 2018 9am&lt;BR /&gt;
message: end&lt;BR /&gt;
status: success&lt;BR /&gt;
event 2:&lt;BR /&gt;
timestamp: June 11, 2018 9:15am&lt;BR /&gt;
message: end&lt;BR /&gt;
status: failed&lt;/P&gt;

&lt;P&gt;event 3:&lt;BR /&gt;
timestamp: June 11, 2018 10am&lt;BR /&gt;
message: end&lt;BR /&gt;
status: success&lt;BR /&gt;
event 3:&lt;BR /&gt;
timestamp: June 11, 2018 10:15am&lt;BR /&gt;
message: end&lt;BR /&gt;
status: success&lt;/P&gt;

&lt;P&gt;Then my failure rate % is (1+0)/(2+2)*100 = 25%, &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="index" "message=end" 
          | bin span=1h _time 
          | stats count as complete,
            count(eval(status="failed")) as failed by _time
          | timechart span=1d eval(100*sum(eval(failed))/sum(eval(complete))) as "Failed %"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jun 2018 20:47:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Understanding-bins-and-spans/m-p/443758#M125868</guid>
      <dc:creator>rnayshulis</dc:creator>
      <dc:date>2018-06-11T20:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding bins and spans</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Understanding-bins-and-spans/m-p/443759#M125869</link>
      <description>&lt;P&gt;look like you are making thing very difficult.&lt;BR /&gt;
Please use the below query. it will work&lt;/P&gt;

&lt;P&gt;index="index" "message: end" &lt;BR /&gt;
           | timechart span=1h count as complete &lt;BR /&gt;
           | appendcols  [ search index="index" "message: end" "status: failed"&lt;BR /&gt;
           | timechart span=1h count as failed ] &lt;BR /&gt;
           | eval percentage=failed*100/complete as "Failed %"&lt;/P&gt;

&lt;P&gt;Please let me know if any issues&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 08:54:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Understanding-bins-and-spans/m-p/443759#M125869</guid>
      <dc:creator>logloganathan</dc:creator>
      <dc:date>2018-06-12T08:54:51Z</dc:date>
    </item>
  </channel>
</rss>

