<?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: Use an eval statement to find a percentage in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Use-an-eval-statement-to-find-a-percentage/m-p/552115#M156684</link>
    <description>&lt;P&gt;It would be helpful to know what results you get from that query, but I expect you get no results.&amp;nbsp; If you do get results then they're likely to be inaccurate because the blockedAction field is a label rather than a count.&lt;/P&gt;&lt;P&gt;Try this variation on your query.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=proxy sourcetype=bar
| stats count as grandTotal, sum(eval(blockedAction="blocked")) as blockedCount
| eval percentBlocked = round((blockedCount/grandTotal)*100,1)&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 18 May 2021 23:31:04 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2021-05-18T23:31:04Z</dc:date>
    <item>
      <title>Use an eval statement to find a percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-an-eval-statement-to-find-a-percentage/m-p/552095#M156679</link>
      <description>&lt;P&gt;&lt;SPAN&gt;index=proxy sourcetype=bar&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| stats count by blockedAction&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| addtotals fieldname=grandTotal&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval percentBlocked = round((blockedAction/grandTotal)*100,1)&lt;BR /&gt;&lt;BR /&gt;I'm trying to show the amount blocked as a percent of total traffic. BlockedAction is a field that was created.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 20:18:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-an-eval-statement-to-find-a-percentage/m-p/552095#M156679</guid>
      <dc:creator>jregexsaurus</dc:creator>
      <dc:date>2021-05-18T20:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Use an eval statement to find a percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-an-eval-statement-to-find-a-percentage/m-p/552114#M156683</link>
      <description>&lt;P&gt;The simplest way is to use the top command&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=proxy sourcetype=bar
| top 0 blockedAction&lt;/LI-CODE&gt;&lt;P&gt;but you can do this other ways, such as&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=proxy sourcetype=bar
| stats count by blockedAction
| eventstats sum(count) as grandTotal
| eval percentBlocked = round((count/grandTotal)*100,1)
| fields - grandTotal&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 23:24:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-an-eval-statement-to-find-a-percentage/m-p/552114#M156683</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-05-18T23:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Use an eval statement to find a percentage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-an-eval-statement-to-find-a-percentage/m-p/552115#M156684</link>
      <description>&lt;P&gt;It would be helpful to know what results you get from that query, but I expect you get no results.&amp;nbsp; If you do get results then they're likely to be inaccurate because the blockedAction field is a label rather than a count.&lt;/P&gt;&lt;P&gt;Try this variation on your query.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=proxy sourcetype=bar
| stats count as grandTotal, sum(eval(blockedAction="blocked")) as blockedCount
| eval percentBlocked = round((blockedCount/grandTotal)*100,1)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 18 May 2021 23:31:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-an-eval-statement-to-find-a-percentage/m-p/552115#M156684</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-05-18T23:31:04Z</dc:date>
    </item>
  </channel>
</rss>

