<?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 write a search to calculate percentages for success and failure rates from my user log data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229614#M68001</link>
    <description>&lt;P&gt;I am trying to write a search that reports the percentage of total users impacted from log data.  &lt;/P&gt;

&lt;P&gt;// All users will have this line recorded&lt;BR /&gt;
initializing user blah blah&lt;/P&gt;

&lt;P&gt;// success user will have this line recorded&lt;BR /&gt;
init succeeded&lt;/P&gt;

&lt;P&gt;// fail users will have a few variations&lt;BR /&gt;
init failed A&lt;BR /&gt;
init failed B&lt;/P&gt;

&lt;P&gt;How do I write a search that counts the occurrences of these strings and calculate a percentage from there?  Also preferably, I would like to use the userid field to only count each user once.&lt;BR /&gt;&lt;BR /&gt;
The report would look something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Total User | Success Rate | Failure Rates
53334      |     99%      |    1%
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried using the append command to combine the counting of each result, but it is too slow.  I was hoping for a more streamline answer. Thank you very much&lt;/P&gt;</description>
    <pubDate>Tue, 01 Mar 2016 20:33:49 GMT</pubDate>
    <dc:creator>trunghung</dc:creator>
    <dc:date>2016-03-01T20:33:49Z</dc:date>
    <item>
      <title>How to write a search to calculate percentages for success and failure rates from my user log data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229614#M68001</link>
      <description>&lt;P&gt;I am trying to write a search that reports the percentage of total users impacted from log data.  &lt;/P&gt;

&lt;P&gt;// All users will have this line recorded&lt;BR /&gt;
initializing user blah blah&lt;/P&gt;

&lt;P&gt;// success user will have this line recorded&lt;BR /&gt;
init succeeded&lt;/P&gt;

&lt;P&gt;// fail users will have a few variations&lt;BR /&gt;
init failed A&lt;BR /&gt;
init failed B&lt;/P&gt;

&lt;P&gt;How do I write a search that counts the occurrences of these strings and calculate a percentage from there?  Also preferably, I would like to use the userid field to only count each user once.&lt;BR /&gt;&lt;BR /&gt;
The report would look something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Total User | Success Rate | Failure Rates
53334      |     99%      |    1%
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried using the append command to combine the counting of each result, but it is too slow.  I was hoping for a more streamline answer. Thank you very much&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 20:33:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229614#M68001</guid>
      <dc:creator>trunghung</dc:creator>
      <dc:date>2016-03-01T20:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to calculate percentages for success and failure rates from my user log data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229615#M68002</link>
      <description>&lt;P&gt;Do you have the status (failed/succeeded) available as a field? It's tricky to help without knowing what you have to work with. If you have a field, it will be pretty simple to stats count successes and failures, and calculate the totals and percentages from those two values.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 23:24:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229615#M68002</guid>
      <dc:creator>s2_splunk</dc:creator>
      <dc:date>2016-03-01T23:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to calculate percentages for success and failure rates from my user log data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229616#M68003</link>
      <description>&lt;P&gt;yeah I do have a field called Type=ERROR when it is a failure.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2016 23:39:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229616#M68003</guid>
      <dc:creator>trunghung</dc:creator>
      <dc:date>2016-03-01T23:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to calculate percentages for success and failure rates from my user log data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229617#M68004</link>
      <description>&lt;P&gt;yoursearch |stats count AS "Total",count(eval(Type=="ERROR")) AS Failure|eval Faliurerate=(Failure/Total)*100|eval  successrate=100-Faliurerate|table Total,successrate,Failurerate&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 06:46:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229617#M68004</guid>
      <dc:creator>sameera123</dc:creator>
      <dc:date>2016-03-02T06:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to calculate percentages for success and failure rates from my user log data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229618#M68005</link>
      <description>&lt;P&gt;In the absence of real sample logs, something like this should get you close: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yourSearch 
 | stats count(eval(match(Type, "ERROR"))) AS f, count as t 
 | eval s = t-f, percF = (f/t)*100, percS=100-percF 
 | rename t as Total, percF as FailureRate, percS as SuccessRate 
 | table Total, FailureRate, SuccessRate
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Mar 2016 06:54:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229618#M68005</guid>
      <dc:creator>s2_splunk</dc:creator>
      <dc:date>2016-03-02T06:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to calculate percentages for success and failure rates from my user log data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229619#M68006</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
This will help&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_* status=*|stats count(user) as Total_user|appendcols[search index=_* status=success|stats count(user) as success_user]|appendcols[search index=_* status=failure|stats count(user) as fail_user]|eval successRate=((success_user/Total_user)*100)."%", failureRate=((fail_user/Total_user)*100)."%"|table Total_user successRate failureRate
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Look at the result&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/1099i2058901A6D322645/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 10:53:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229619#M68006</guid>
      <dc:creator>chimell</dc:creator>
      <dc:date>2016-03-02T10:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to calculate percentages for success and failure rates from my user log data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229620#M68007</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;your_base_search |stats count AS "T",count(eval(Type=="ERROR")) AS Failure|eval pF=round((Failure/T)*100), "Success Rate"=100-pF|table T,"Success Rate",pF|rename pF as "Failure Rates",  T as "Total User"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Mar 2016 12:18:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229620#M68007</guid>
      <dc:creator>fdi01</dc:creator>
      <dc:date>2016-03-02T12:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to calculate percentages for success and failure rates from my user log data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229621#M68008</link>
      <description>&lt;P&gt;Good Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2016 08:30:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-calculate-percentages-for-success-and/m-p/229621#M68008</guid>
      <dc:creator>chimell</dc:creator>
      <dc:date>2016-03-03T08:30:07Z</dc:date>
    </item>
  </channel>
</rss>

