<?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 How to display success rate as 100 if no API calls are invoked? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-success-rate-as-100-if-no-API-calls-are-invoked/m-p/292044#M88203</link>
    <description>&lt;P&gt;Please help me in the below search query &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=Index1 sourcetype="Tablename" CounterName="Number of Successful API calls" OR CounterName="Number of Failed API calls" OR CounterName="Number of Request API calls" 
| eval Fail=if(match(CounterName,"Number of Failed API calls"),Value,0) 
| eval Success=if(match(CounterName,"Number of Successful API calls"),Value,0) 
| eval Total =Success+Fail 
| eventstats sum(Success) as Success,Sum(Total) as Total by CounterApiName 
| eval SuccessRate= (Success/Total)*100 
| timechart limit=10000 span=30m values(SuccessRate) by CounterApiName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is showing as 0.00% when no API calls were triggered. I need to display 100% as success rate if no API calls are triggered &lt;/P&gt;</description>
    <pubDate>Tue, 20 Feb 2018 15:41:37 GMT</pubDate>
    <dc:creator>rgopal88</dc:creator>
    <dc:date>2018-02-20T15:41:37Z</dc:date>
    <item>
      <title>How to display success rate as 100 if no API calls are invoked?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-success-rate-as-100-if-no-API-calls-are-invoked/m-p/292044#M88203</link>
      <description>&lt;P&gt;Please help me in the below search query &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=Index1 sourcetype="Tablename" CounterName="Number of Successful API calls" OR CounterName="Number of Failed API calls" OR CounterName="Number of Request API calls" 
| eval Fail=if(match(CounterName,"Number of Failed API calls"),Value,0) 
| eval Success=if(match(CounterName,"Number of Successful API calls"),Value,0) 
| eval Total =Success+Fail 
| eventstats sum(Success) as Success,Sum(Total) as Total by CounterApiName 
| eval SuccessRate= (Success/Total)*100 
| timechart limit=10000 span=30m values(SuccessRate) by CounterApiName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is showing as 0.00% when no API calls were triggered. I need to display 100% as success rate if no API calls are triggered &lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2018 15:41:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-success-rate-as-100-if-no-API-calls-are-invoked/m-p/292044#M88203</guid>
      <dc:creator>rgopal88</dc:creator>
      <dc:date>2018-02-20T15:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to display success rate as 100 if no API calls are invoked?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-success-rate-as-100-if-no-API-calls-are-invoked/m-p/292045#M88204</link>
      <description>&lt;P&gt;You can just add a check on your penultimate line by replacing this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval SuccessRate= (Success/Total)*100 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;with:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval SuccessRate=if(Total=0, 100, (Success/Total)*100 )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That way, if Total was 0, then your SuccessRate will be 100, as desired. If Total was not 0, then it will be calculated as usual.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2018 16:02:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-success-rate-as-100-if-no-API-calls-are-invoked/m-p/292045#M88204</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-02-20T16:02:42Z</dc:date>
    </item>
  </channel>
</rss>

