<?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: How to calculate the availability of an application using the number of errors per minute? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-availability-of-an-application-using-the/m-p/131485#M35867</link>
    <description>&lt;P&gt;As a starter, you are using the "as" incorrectly in your first stats &lt;CODE&gt;...|stats  count  by _time as t_err |...&lt;/CODE&gt;, you need to use rename in this case if you are renaming _time &lt;CODE&gt;... | stats  count  by _time as t_err | rename _time as t_err | ...&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Also, rather than trying to use rename I suggest you use "AS" inside of the timechart command itself. Like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Error"    | bucket span=1m _time | stats count by _time as t_err | rename _time as t_err | eval avail=86400-t_err | eval AvailPct = round((avail/86400)*100,2)| timechart span=1m sum(AvailPct) as "Avail.Pct"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 28 Sep 2020 18:50:40 GMT</pubDate>
    <dc:creator>aholzer</dc:creator>
    <dc:date>2020-09-28T18:50:40Z</dc:date>
    <item>
      <title>How to calculate the availability of an application using the number of errors per minute?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-availability-of-an-application-using-the/m-p/131483#M35865</link>
      <description>&lt;P&gt;I want to calculate availability of an application. The logic i am using is number of errors per minute.&lt;BR /&gt;
So I am searching by _time and trying to get availability. The result is not returned.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Error"    | bucket span=1m _time   |  stats  count by _time as t_err | eval avail=86400-t_err |  eval AvailPct = round((avail/86400)*100,2)| timechart span=1m sum(AvailPct)|RENAME sum(AvailPct) as "Avail.Pct"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Feb 2015 18:36:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-availability-of-an-application-using-the/m-p/131483#M35865</guid>
      <dc:creator>nravichandran</dc:creator>
      <dc:date>2015-02-05T18:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the availability of an application using the number of errors per minute?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-availability-of-an-application-using-the/m-p/131484#M35866</link>
      <description>&lt;P&gt;First, I think there is a problem with your math - for each &lt;EM&gt;minute&lt;/EM&gt;, you are calculating the number of errors, and the subtracting that from the number of &lt;EM&gt;seconds&lt;/EM&gt; in a day.  &lt;/P&gt;

&lt;P&gt;I think you will better off deciding what is "up" and what is "down", and then determining (by minute or second) if the application is available. For that time slot, availability is not a percentage, it is binary (up or down). An availability percentage only makes sense across a time frame, such as a day.&lt;/P&gt;

&lt;P&gt;Here is an idea for the chart:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Error"    
| bucket span=1m _time   
| stats  count by _time as t_err 
| t_err=if(t_err&amp;gt;0,1,0)
| timechart span=1m max(t_err) as status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In this chart, the entire minute is counted as "down" if there were &lt;EM&gt;any&lt;/EM&gt; errors during that minute. If you show this as a bar chart, there will be a spike on the bar for each minute where the application was "down".&lt;/P&gt;

&lt;P&gt;To calculate the availability percentage by day:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Error"    
| bucket span=1s _time   
| stats  count by _time as t_err 
| t_err=if(t_err&amp;gt;0,1,0)
| bucket span=1d _time
| stats sum(t_err) as totalSecsDown by _time
| eval Percent_Available = round((86400-totalSecsDown)*100/86400,2)
| timechart span=1d max(Percent_Available) as Avail.Pct
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This calculates an availability percentage by day, based on the number of seconds down.&lt;/P&gt;

&lt;P&gt;Note that in both cases, I defined t_err to be "1" if there are any errors. That way, when Splunk adds up t_err, it is the number of seconds (or minutes), not the number of errors.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:50:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-availability-of-an-application-using-the/m-p/131484#M35866</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2020-09-28T18:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the availability of an application using the number of errors per minute?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-availability-of-an-application-using-the/m-p/131485#M35867</link>
      <description>&lt;P&gt;As a starter, you are using the "as" incorrectly in your first stats &lt;CODE&gt;...|stats  count  by _time as t_err |...&lt;/CODE&gt;, you need to use rename in this case if you are renaming _time &lt;CODE&gt;... | stats  count  by _time as t_err | rename _time as t_err | ...&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Also, rather than trying to use rename I suggest you use "AS" inside of the timechart command itself. Like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Error"    | bucket span=1m _time | stats count by _time as t_err | rename _time as t_err | eval avail=86400-t_err | eval AvailPct = round((avail/86400)*100,2)| timechart span=1m sum(AvailPct) as "Avail.Pct"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:50:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-availability-of-an-application-using-the/m-p/131485#M35867</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2020-09-28T18:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the availability of an application using the number of errors per minute?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-availability-of-an-application-using-the/m-p/131486#M35868</link>
      <description>&lt;P&gt;Thanks. When i used the second one (which is what i am looking for) i got error and modified by adding eval but did not get any results as chart but results are returned in the events, no visuvalization or stats.&lt;/P&gt;

&lt;P&gt;"Error"&lt;BR /&gt;&lt;BR /&gt;
 | bucket span=1s _time&lt;BR /&gt;&lt;BR /&gt;
 | stats  count by _time as t_err &lt;BR /&gt;
 |eval t_err=if(t_err&amp;gt;0,1,0)&lt;BR /&gt;
 | bucket span=1d _time&lt;BR /&gt;
 | stats sum(t_err) as totalSecsDown by _time&lt;BR /&gt;
 | eval Percent_Available = round((86400-totalSecsDown)*100/86400,2)&lt;BR /&gt;
 | timechart span=1d max(Percent_Available) as Avail.Pct&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:51:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-availability-of-an-application-using-the/m-p/131486#M35868</guid>
      <dc:creator>nravichandran</dc:creator>
      <dc:date>2020-09-28T18:51:39Z</dc:date>
    </item>
  </channel>
</rss>

