<?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 uptime based on below result, (total no of up events)*100/(total no of events) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44709#M179213</link>
    <description>&lt;P&gt;One alternative approach could work something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=result
| eval up_int=if(status="Up",1,0)
| stats count as num_events, sum(up_int) as num_up
| eval num_down=num_events - num_up
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 27 Aug 2012 15:18:24 GMT</pubDate>
    <dc:creator>dwaddle</dc:creator>
    <dc:date>2012-08-27T15:18:24Z</dc:date>
    <item>
      <title>how to calculate uptime based on below result, (total no of up events)*100/(total no of events)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44708#M179212</link>
      <description>&lt;P&gt;8/27/12 10:24:04.000 AM server=Test and status=Up host=test1 &lt;BR /&gt;
8/27/12 10:24:04.000 AM server=test1 and status=Up host=test1 &lt;BR /&gt;
8/27/12 10:24:04.000 AM server=test2 and status=Down host=test1 &lt;BR /&gt;
8/27/12 10:24:00.000 AM server=test3 and status=Up host=test1 &lt;BR /&gt;
8/27/12 10:23:04.000 AM server=test4 and status=Down host=test1 &lt;/P&gt;

&lt;P&gt;i tried running the query:&lt;BR /&gt;
sourcetype="result"| stats count as num_events , count(eval(status=Up)) as upevent by server&lt;BR /&gt;
but not working as expected, unable to get the numbers of up event and total events together&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2012 14:47:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44708#M179212</guid>
      <dc:creator>ajaysingh3</dc:creator>
      <dc:date>2012-08-27T14:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate uptime based on below result, (total no of up events)*100/(total no of events)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44709#M179213</link>
      <description>&lt;P&gt;One alternative approach could work something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=result
| eval up_int=if(status="Up",1,0)
| stats count as num_events, sum(up_int) as num_up
| eval num_down=num_events - num_up
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Aug 2012 15:18:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44709#M179213</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2012-08-27T15:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate uptime based on below result, (total no of up events)*100/(total no of events)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44710#M179214</link>
      <description>&lt;P&gt;thanks dwaddle,&lt;/P&gt;

&lt;P&gt;i have modified above search to &lt;BR /&gt;
sourcetype=result| eval up_int=if(status="Up",1,0)| stats count as num_events , sum(up_int) as num_up| eval uptime=num_up*100/num_events&lt;/P&gt;

&lt;P&gt;result:&lt;BR /&gt;
 num_events  num_up  uptime&lt;BR /&gt;&lt;BR /&gt;
1 366 305 83.333333 &lt;/P&gt;

&lt;P&gt;how can we get the result by server&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:20:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44710#M179214</guid>
      <dc:creator>ajaysingh3</dc:creator>
      <dc:date>2020-09-28T12:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate uptime based on below result, (total no of up events)*100/(total no of events)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44711#M179215</link>
      <description>&lt;P&gt;sourcetype=result&lt;BR /&gt;
| eval up_int=if(status="Up",1,0)&lt;BR /&gt;
| stats count as num_events, sum(up_int) as num_up by server&lt;BR /&gt;
| eval num_down=num_events - num_up&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:20:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44711#M179215</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2020-09-28T12:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate uptime based on below result, (total no of up events)*100/(total no of events)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44712#M179216</link>
      <description>&lt;P&gt;thanks, working fine...&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2012 18:07:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44712#M179216</guid>
      <dc:creator>ajaysingh3</dc:creator>
      <dc:date>2012-08-27T18:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate uptime based on below result, (total no of up events)*100/(total no of events)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44713#M179217</link>
      <description>&lt;P&gt;I wonder if your formula really represents uptime. I would calculate it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=result | fields server | dedup server 
| map [ search sourcetype=result server=$server$  | sort _time | delta _time as timeDelta 
      | streamstats last(status) as lastStatus 
      | status  sum(eval(lastStatus="Down")) as downtime sum(eval(lastStatus="Up")) as uptime 
      | eval percentUptime = round((uptime*100)/(uptime+downtime),1)
      | fields server, uptime, downtime, percentUptime ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Aug 2012 18:11:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44713#M179217</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-08-27T18:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate uptime based on below result, (total no of up events)*100/(total no of events)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44714#M179218</link>
      <description>&lt;P&gt;this is working for me and giving correct uptime...&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2012 11:54:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44714#M179218</guid>
      <dc:creator>ajaysingh3</dc:creator>
      <dc:date>2012-08-28T11:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate uptime based on below result, (total no of up events)*100/(total no of events)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44715#M179219</link>
      <description>&lt;P&gt;sourcetype=result| eval up_int=if(status="Up",1,0)| stats count as num_events, sum(up_int) as num_up by server|  eval uptime=num_up*100/num_events|fields server uptime&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:20:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44715#M179219</guid>
      <dc:creator>ajaysingh3</dc:creator>
      <dc:date>2020-09-28T12:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate uptime based on below result, (total no of up events)*100/(total no of events)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44716#M179220</link>
      <description>&lt;P&gt;Just add the "by" clause to the stats command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=result| eval up_int=if(status="Up",1,0)| stats count as num_events , sum(up_int) as num_up by host| eval uptime=num_up*100/num_events
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Sep 2012 08:19:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-uptime-based-on-below-result-total-no-of-up/m-p/44716#M179220</guid>
      <dc:creator>Simon</dc:creator>
      <dc:date>2012-09-27T08:19:22Z</dc:date>
    </item>
  </channel>
</rss>

