<?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: Help with a query to calculate percentage in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-a-query-to-calculate-percentage/m-p/651139#M16858</link>
    <description>&lt;P&gt;Your search looks a little odd for what you are trying to do although it does depend on your data.&lt;/P&gt;&lt;P&gt;Since you have _time in your by clause, it is likely that your success count is likely to be either 1 or zero, same with the inprogress count.&lt;/P&gt;&lt;P&gt;If you remove the _time from your by clause, you will get the counts across the whole of the time period of the search (which might be what you actually want)&lt;/P&gt;&lt;P&gt;You can then do an eval based on your criteria for success or failure and count those again over the time period of your search using another stats command.&lt;/P&gt;&lt;P&gt;Finally, you can do an eval to determine the percentage success of all the events within the time period&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jul 2023 15:35:13 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2023-07-19T15:35:13Z</dc:date>
    <item>
      <title>Help with a query to calculate percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-a-query-to-calculate-percentage/m-p/651133#M16857</link>
      <description>&lt;P&gt;Hello, I am working on a query where I need to set an alert based on failure percentages. Calculating the failure percentage is the tricky part. Here is my sample query -&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=myindex  (status=success OR status=inprogress) 
| bin _time 
| stats count(eval(like(status, "success"))) as success count(eval(like(status, "inprogress"))) as inprogress by id _time &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The conditions for access and failure are as below -&lt;/P&gt;&lt;P&gt;Success -&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where success = 1 AND inprogress &amp;gt;=1&lt;/LI-CODE&gt;&lt;P&gt;Failure -&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where success = 0 AND inprogress &amp;gt;=1&lt;/LI-CODE&gt;&lt;P&gt;Now I want to create an alert based on failure percentage of 10%. How do i calculate the failure and success percentage here? The id you are seeing in the BY clause is nothing but customer ID so I'd like to get alerted based on 10% failure,&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 15:06:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-a-query-to-calculate-percentage/m-p/651133#M16857</guid>
      <dc:creator>sunny_871</dc:creator>
      <dc:date>2023-07-19T15:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a query to calculate percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-a-query-to-calculate-percentage/m-p/651139#M16858</link>
      <description>&lt;P&gt;Your search looks a little odd for what you are trying to do although it does depend on your data.&lt;/P&gt;&lt;P&gt;Since you have _time in your by clause, it is likely that your success count is likely to be either 1 or zero, same with the inprogress count.&lt;/P&gt;&lt;P&gt;If you remove the _time from your by clause, you will get the counts across the whole of the time period of the search (which might be what you actually want)&lt;/P&gt;&lt;P&gt;You can then do an eval based on your criteria for success or failure and count those again over the time period of your search using another stats command.&lt;/P&gt;&lt;P&gt;Finally, you can do an eval to determine the percentage success of all the events within the time period&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 15:35:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-a-query-to-calculate-percentage/m-p/651139#M16858</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-07-19T15:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a query to calculate percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-a-query-to-calculate-percentage/m-p/651150#M16859</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;Thanks for the response. I have removed the _time.&lt;/P&gt;&lt;P&gt;Sorry how would i create or generate an eval with the below success and failure conditions? Could you give me a guidance.,&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Shashank&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 17:26:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-a-query-to-calculate-percentage/m-p/651150#M16859</guid>
      <dc:creator>sunny_871</dc:creator>
      <dc:date>2023-07-19T17:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a query to calculate percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-a-query-to-calculate-percentage/m-p/651151#M16860</link>
      <description>&lt;LI-CODE lang="markup"&gt;| eval status=case(success = 1 AND inprogress &amp;gt;=1, "success", success = 0 AND inprogress &amp;gt;=1, "failure")&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 19 Jul 2023 17:53:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-a-query-to-calculate-percentage/m-p/651151#M16860</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-07-19T17:53:23Z</dc:date>
    </item>
  </channel>
</rss>

