<?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: Calculate after stats command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calculate-after-stats-command/m-p/559467#M158939</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231845"&gt;@jariw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you looking for this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval _raw="index,compliant_host,chost
main,0,11
main,1,123
msad,1,6
nmon,1,5
openshift,1,1
temp_log,1,1
wineventlog,1,2"| multikv forceheader=1
| table index,compliant_host,chost | eventstats sum(chost) as total by index | eval percentage=round((chost/total)*100,2) | fields - total&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;KV&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jul 2021 16:51:21 GMT</pubDate>
    <dc:creator>kamlesh_vaghela</dc:creator>
    <dc:date>2021-07-14T16:51:21Z</dc:date>
    <item>
      <title>Calculate after stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-after-stats-command/m-p/559391#M158931</link>
      <description>&lt;P&gt;L.s.,&lt;/P&gt;&lt;P&gt;I want to get the latency from the input from a forwarder to an index. So whe use the app Meta_woot. It creates an inputlookup file &lt;EM&gt;meta-woot&lt;/EM&gt;. In this file are the latest in-time and host names and index names. So far so good.&lt;/P&gt;&lt;P&gt;Next is to use this file for calculating&amp;nbsp; if a host is late or recent or delayed. Those searches are in the app and works fine. But i want a little extension, i want a table with the indexes as leading, and then calculate (by index) the percentage recent/late host, and sum it a one outcome (per index)&lt;/P&gt;&lt;P&gt;So far the theory, now my tries. I used below serach.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;| inputlookup meta_woot where index=*&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| eval convert_late=(1440*60) &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| eval convert_delayed=(60*60)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| eval last_time=(now()-recentTime)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| eval last_time_indexed=case(last_time &amp;lt; convert_delayed, "Recent", last_time &amp;gt; convert_late, "Late", last_time &amp;gt; convert_delayed, "Delayed") &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| eval compliant_host=if(last_time_indexed="Recent", "1","0")&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;| stats count(compliant_host) as chost by index, compliant_host&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;This gives me a result where the outcome has split into indexname vs compliant_host and chost&lt;/P&gt;&lt;P&gt;index compliant_host chost&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;main&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;main&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;msad&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;nmon&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;openshift&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;temp_log&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;wineventlog&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now the question, how do i calculate the percentage for index main ( (123+11)/11) so i get an percentage value. How do i calculate with values after a stats command??&lt;/P&gt;&lt;P&gt;Pls help&lt;/P&gt;&lt;P&gt;Thanx in advance&lt;/P&gt;&lt;P&gt;greetz&lt;/P&gt;&lt;P&gt;Jari&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 10:15:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-after-stats-command/m-p/559391#M158931</guid>
      <dc:creator>jariw</dc:creator>
      <dc:date>2021-07-14T10:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate after stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-after-stats-command/m-p/559467#M158939</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231845"&gt;@jariw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you looking for this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval _raw="index,compliant_host,chost
main,0,11
main,1,123
msad,1,6
nmon,1,5
openshift,1,1
temp_log,1,1
wineventlog,1,2"| multikv forceheader=1
| table index,compliant_host,chost | eventstats sum(chost) as total by index | eval percentage=round((chost/total)*100,2) | fields - total&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;KV&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 16:51:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-after-stats-command/m-p/559467#M158939</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-07-14T16:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate after stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-after-stats-command/m-p/559530#M158955</link>
      <description>&lt;P&gt;Hi KV,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanx for the answer. it give me some clues to work with. The only (and i think diffiuct thing) is that i want to group the results from the "main" and calculate between those two.&lt;/P&gt;&lt;P&gt;"main"has two type's ,&lt;/P&gt;&lt;P&gt;one with the compliant_host with value 0, and total 11&lt;/P&gt;&lt;P&gt;one with the compliant_host with value 1, and total&amp;nbsp; 123&lt;/P&gt;&lt;P&gt;I want tot calculate between those two.. ((123+11)/11)*100&amp;nbsp; for the (total amount in main/11)*100&lt;/P&gt;&lt;P&gt;I think the hardest problem is the grouping off the "main" en then calculate witth it.&lt;/P&gt;&lt;P&gt;grts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jari&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 06:42:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-after-stats-command/m-p/559530#M158955</guid>
      <dc:creator>jariw</dc:creator>
      <dc:date>2021-07-15T06:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate after stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-after-stats-command/m-p/559558#M158971</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231845"&gt;@jariw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please try this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="index,compliant_host,chost
main,0,11
main,1,123
msad,1,6
nmon,1,5
openshift,1,1
temp_log,1,1
wineventlog,1,2" 
| multikv forceheader=1 
| table index,compliant_host,chost 
| stats sum(chost) as total list(chost) as chost by index | eval chost=mvindex(chost,0)
| eval percentage=round((total/chost)*100,2)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 15 Jul 2021 08:33:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-after-stats-command/m-p/559558#M158971</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-07-15T08:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate after stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calculate-after-stats-command/m-p/560168#M159193</link>
      <description>&lt;P&gt;Hi KV,&lt;/P&gt;&lt;P&gt;Sorry for the late answer, i had a free long weekend.&lt;/P&gt;&lt;P&gt;I think i see it now. I don't have to group it indeed, just get the one's with value "0" for the complian_host. If that one is above 33 % then i want a warning.&lt;/P&gt;&lt;P&gt;I think i can write this one &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks foor the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;grts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jari&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 06:56:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calculate-after-stats-command/m-p/560168#M159193</guid>
      <dc:creator>jariw</dc:creator>
      <dc:date>2021-07-20T06:56:05Z</dc:date>
    </item>
  </channel>
</rss>

