<?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: Need help with eval in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-eval/m-p/433304#M123738</link>
    <description>&lt;P&gt;@Dsrao12345,&lt;/P&gt;

&lt;P&gt;Add this to your search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats sum(count) as total
| eval perc=round((count/total)*100,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And your original search probably could be modified as &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (index=index1  OR  index=index2) "PrepareResponseTime= "  
 |rex "PreResponseTime= (?[0-9]) ms"
 |eval ResponseTime=if(PrepareResponseTime &amp;lt;1000,"count &amp;lt;1000","count &amp;gt;1000" )
 |stats count by index,ResponseTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 06 Aug 2019 12:50:46 GMT</pubDate>
    <dc:creator>renjith_nair</dc:creator>
    <dc:date>2019-08-06T12:50:46Z</dc:date>
    <item>
      <title>Need help with eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-eval/m-p/433303#M123737</link>
      <description>&lt;P&gt;my search query :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index1"PrepareResponseTime= " 
| rex "PreResponseTime= (?[0-9]*) ms"  
| where PrepareResponseTime &amp;gt; 1000 
| eval PrepareResponseTime= "count &amp;gt;1000"  
| stats count by index,PrepareOrderResponseTime 
| append [search index=index2 "PrepareResponseTime= " 
| rex "PrepareResponseTime= (?[0-9]*) ms"  
| where PrepareResponseTime &amp;lt; 1000 | eval PrepareResponseTime= "count &amp;lt;1000"  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;statistics results:&lt;/P&gt;

&lt;P&gt;indexname       PrepareResponseTime     count&lt;BR /&gt;
=========       =================== =====&lt;BR /&gt;
index1          count &amp;gt;1000         1486&lt;BR /&gt;
index2          count &amp;lt;1000         6639&lt;/P&gt;

&lt;P&gt;I would like to using eval calculate percentage like below:&lt;/P&gt;

&lt;P&gt;(1486 * 100) / (1486 + 6639) = %&lt;/P&gt;

&lt;P&gt;148600/8125 = 18.289 (round)&lt;/P&gt;

&lt;P&gt;After using calculations results to be like :&lt;/P&gt;

&lt;P&gt;round 18.29%&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 11:16:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-eval/m-p/433303#M123737</guid>
      <dc:creator>Dsrao12345</dc:creator>
      <dc:date>2019-08-06T11:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with eval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-eval/m-p/433304#M123738</link>
      <description>&lt;P&gt;@Dsrao12345,&lt;/P&gt;

&lt;P&gt;Add this to your search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats sum(count) as total
| eval perc=round((count/total)*100,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And your original search probably could be modified as &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (index=index1  OR  index=index2) "PrepareResponseTime= "  
 |rex "PreResponseTime= (?[0-9]) ms"
 |eval ResponseTime=if(PrepareResponseTime &amp;lt;1000,"count &amp;lt;1000","count &amp;gt;1000" )
 |stats count by index,ResponseTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Aug 2019 12:50:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-eval/m-p/433304#M123738</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-08-06T12:50:46Z</dc:date>
    </item>
  </channel>
</rss>

