<?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 on complex stats command in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572823#M10511</link>
    <description>&lt;P&gt;How about this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=toto sourcetype=:request web_domain="*" web_status=* 
| stats count(web_status) as nbstatus by web_domain
| eventstats dc(web_domain) as nbdomain
| stats sum(nbstatus) as nbstatus max(nbdomain) as nbdomain
| eval prcerreur = round(nbdomain/nbstatus*100,1). " %" 
| table prcerreur&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 28 Oct 2021 13:40:17 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2021-10-28T13:40:17Z</dc:date>
    <item>
      <title>help on complex stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572702#M10492</link>
      <description>&lt;P&gt;hello&lt;/P&gt;&lt;P&gt;I need to calculate a percentage value from 2 differents stats&amp;nbsp;&lt;/P&gt;&lt;P&gt;First I tried to do something like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=toto sourcetype=:request web_domain="*" web_status=*  
| stats dc(web_domain) as nbdomain, count(web_status) as nbdomainko
| eval KO=round(nbdomain/nbdomainko*100,1)
| table KO&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it returns a result but it's wrong because I need to count the web_status by web_domain in order to count the number of web_status by web_domain for being able to calculate my percentage value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats dc(web_domain) as nbdomain, count(web_status) as nbdomainko by web_domain&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I try to separate the 2 search with an append command but it returns anything&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=toto sourcetype=request web_domain="*" web_status=* 
| stats dc(web_domain) as nbdomain 
| append 
    [ search index=toto sourcetype=:request web_domain="*" web_status=* 
    | stats count(web_status) as nbstatus by web_domain] 
| eval prcerreur = round(nbdomain/nbstatus*100,1). " %" 
| table prcerreur&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so what is the best way to solve my use case please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 16:40:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572702#M10492</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2021-10-27T16:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: help on complex stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572718#M10493</link>
      <description>&lt;P&gt;Can you post some dummy/sample data and corresponding output? It would help understand your requirement.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 17:48:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572718#M10493</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2021-10-27T17:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: help on complex stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572724#M10494</link>
      <description>&lt;P&gt;Sorry its not&amp;nbsp; to send lors on this topic&amp;nbsp;&lt;/P&gt;&lt;P&gt;But i am going to be more precise&lt;/P&gt;&lt;P&gt;I need to calculate a pourcentage from 2 fields&lt;/P&gt;&lt;P&gt;First i have to count the number of différent web_domain = its ok&amp;nbsp;&lt;/P&gt;&lt;P&gt;After i need to count the number of web_status but mandatory by web_domain because the first search count the web_domain so the second search has to also filter the events by web_domain because the pourcentage i want is the availability percentage of all the web_domain = its ok too&lt;/P&gt;&lt;P&gt;But what i dont succeed is to cross the 2 search un ordre to be table to calcul the percentage which consists in divising the result of the first search by the result of the second search....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 18:18:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572724#M10494</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2021-10-27T18:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: help on complex stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572727#M10495</link>
      <description>&lt;P&gt;If I understand you correctly, you want to perform two different aggregating calculations and your problem is that with each of them you lose the original data so cannot calculate the other one, right?&lt;/P&gt;&lt;P&gt;Use eventstats. This way you append the results to the original events.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 19:14:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572727#M10495</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-10-27T19:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: help on complex stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572729#M10496</link>
      <description>&lt;P&gt;Yes right&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am going to try..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 19:17:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572729#M10496</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2021-10-27T19:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: help on complex stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572764#M10499</link>
      <description>&lt;P&gt;If I understand you correctly the way to do this is&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=toto sourcetype=:request web_domain="*" web_status=* 
| stats count(web_status) as nbstatus by web_domain
| eventstats dc(web_domain) as nbdomain
| eval prcerreur = round(nbdomain/nbstatus*100,1). " %" 
| table prcerreur&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;This is first collecting all the web_status by web_domain.&lt;/P&gt;&lt;P&gt;After this stats, you still have all the web_domains, so just use eventstats to count the unique webdomains and then do your calculation. This will be the most efficient way as the eventstats, which can be an expensive operation, is calculated on your already aggregated data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 01:16:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572764#M10499</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-10-28T01:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: help on complex stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572771#M10500</link>
      <description>&lt;P&gt;unfortunately its no good&lt;/P&gt;&lt;P&gt;I am explaining&lt;/P&gt;&lt;P&gt;evenstats calculate the number of web domain in each line&amp;nbsp;&lt;/P&gt;&lt;P&gt;so the percentage is calculated for each line and its not what I need&lt;/P&gt;&lt;P&gt;I need a global percentage which calculate the number of web domain (like its done with eventstats) divising by the total number of web status which is calculated also for each line&lt;/P&gt;&lt;P&gt;and with your code there is another problem&lt;/P&gt;&lt;P&gt;if the number of web domain is for example 3 and the number of status the percentage is 300% instead 33,3%&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thats the reason why I am doing this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=toto sourcetype="request" web_domain="*" web_status=* 
| stats dc(web_domain) as nbdomain 
| appendcols 
    [ search index=toto sourcetype="request"  web_domain="*" web_status=* 
    | stats count(web_status) as nbstatus ] 
| eval prcerreur = round(nbdomain/nbstatus*100,1). " %" 
| table prcerreur&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it works except that like explained in the subsearch I need to add a clause "by web_domain"...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 04:36:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572771#M10500</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2021-10-28T04:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: help on complex stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572823#M10511</link>
      <description>&lt;P&gt;How about this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=toto sourcetype=:request web_domain="*" web_status=* 
| stats count(web_status) as nbstatus by web_domain
| eventstats dc(web_domain) as nbdomain
| stats sum(nbstatus) as nbstatus max(nbdomain) as nbdomain
| eval prcerreur = round(nbdomain/nbstatus*100,1). " %" 
| table prcerreur&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 28 Oct 2021 13:40:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572823#M10511</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2021-10-28T13:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: help on complex stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572842#M10513</link>
      <description>&lt;P&gt;Hi somesoni&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes it works&lt;/P&gt;&lt;P&gt;But your solution gives the same results that the solution I have proposed that is to say this one even if i dont stats the web_status by domain&lt;/P&gt;&lt;P&gt;So I am a little bit surprised but pearhaps I am mistaken and it's the godd way for doing this!&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=toto sourcetype=request" web_domain="*" web_status=* 
| stats dc(web_domain) as nbdomain 
| appendcols 
    [ search index=toto sourcetype=request" web_domain="*" web_status=* 
    | stats count(web_status) as nbstatus ] 
| eval prcerreur = round(nbdomain/nbstatus*100,2). " %" 
| table prcerreur&lt;/LI-CODE&gt;&lt;P&gt;Thank to you&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 15:19:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/help-on-complex-stats-command/m-p/572842#M10513</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2021-10-28T15:19:21Z</dc:date>
    </item>
  </channel>
</rss>

