<?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 Is it possible to get sum of Top 5 values per field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-sum-of-Top-5-values-per-field/m-p/594547#M206928</link>
    <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;So, I have table with Server Names and their load values&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;Server Load capacity
G1      10
G1      80
G2      6
G2      25
G1      50
G3      15
G2      5  
G4      20
G5      30 

and so on...&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to get sum of top 3 fields by Server?&lt;BR /&gt;&lt;BR /&gt;I can do that if I limit it to just one server by:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;my search | search "Server"="G1" |&amp;nbsp; sort- Load | head 3&amp;nbsp; | stats&lt;/EM&gt; sum(Load)&lt;BR /&gt;&lt;BR /&gt;But I want to know for all servers to see which one is getting highest loads on average.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Apr 2022 14:25:21 GMT</pubDate>
    <dc:creator>ISP8055</dc:creator>
    <dc:date>2022-04-21T14:25:21Z</dc:date>
    <item>
      <title>Is it possible to get sum of Top 5 values per field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-sum-of-Top-5-values-per-field/m-p/594547#M206928</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;So, I have table with Server Names and their load values&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;Server Load capacity
G1      10
G1      80
G2      6
G2      25
G1      50
G3      15
G2      5  
G4      20
G5      30 

and so on...&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to get sum of top 3 fields by Server?&lt;BR /&gt;&lt;BR /&gt;I can do that if I limit it to just one server by:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;my search | search "Server"="G1" |&amp;nbsp; sort- Load | head 3&amp;nbsp; | stats&lt;/EM&gt; sum(Load)&lt;BR /&gt;&lt;BR /&gt;But I want to know for all servers to see which one is getting highest loads on average.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 14:25:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-sum-of-Top-5-values-per-field/m-p/594547#M206928</guid>
      <dc:creator>ISP8055</dc:creator>
      <dc:date>2022-04-21T14:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to get sum of Top 5 values per field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-sum-of-Top-5-values-per-field/m-p/594553#M206930</link>
      <description>&lt;P&gt;This example shows you how you can filter 3 events from each server, which follows your example search&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=1000
| fields - _time
| eval Server="G".((random() % 5)+1)
| eval Load=random() % 100
| streamstats c global=f by Server
| where c&amp;lt;=3
| stats sum(Load) as Load by Server
| sort - Load&lt;/LI-CODE&gt;&lt;P&gt;Like your example, it is not sorting any Load value so will just return the first 3 load figures for each server&lt;/P&gt;&lt;P&gt;If you want to find the highest 3 load values per server then you need to add in the sort command before streamstats, i.e.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=1000
| fields - _time
| eval Server="G".((random() % 5)+1)
| eval Load=random() % 100
| sort - Load
| streamstats c global=f by Server
| where c&amp;lt;=3
| stats sum(Load) as Load by Server
| sort - Load&lt;/LI-CODE&gt;&lt;P&gt;and then of course if you want to take time into account and find the most recent, highest load values, then you would need them in time descending order (default after search).&lt;/P&gt;&lt;P&gt;Hopefully this helps. You can just paste these examples into a search window. They create 1000 random data points for 5 servers and then random Load values for each.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2022 22:53:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-sum-of-Top-5-values-per-field/m-p/594553#M206930</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-04-20T22:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to get sum of Top 5 values per field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-sum-of-Top-5-values-per-field/m-p/594593#M206947</link>
      <description>&lt;LI-CODE lang="markup"&gt;| sort Server -Load
| streamstats count by Server
| eval Load=if(count&amp;lt;=3,Load,null())
| stats sum(Load) as Load by Server&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 21 Apr 2022 07:00:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-sum-of-Top-5-values-per-field/m-p/594593#M206947</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-04-21T07:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to get sum of Top 5 values per field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-sum-of-Top-5-values-per-field/m-p/594972#M207041</link>
      <description>&lt;P&gt;&amp;nbsp;&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;| eval Server="G".((random() % 5)+1)
Will I need this syntax if my all of my actual server names don't start with G? What does this command do?


| eval Load=random() % 
Could you explain what does this syntax do?&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 20:54:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-sum-of-Top-5-values-per-field/m-p/594972#M207041</guid>
      <dc:creator>ISP8055</dc:creator>
      <dc:date>2022-04-22T20:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to get sum of Top 5 values per field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-sum-of-Top-5-values-per-field/m-p/595310#M207180</link>
      <description>&lt;P&gt;This part of those searches&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=1000
| fields - _time
| eval Server="G".((random() % 5)+1)
| eval Load=random() % 100&lt;/LI-CODE&gt;&lt;P&gt;is just code to create 1000 random events with a field 'Server' that has one of 5 different values, in order to present a solution, as I do not have access to your data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 23:52:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-sum-of-Top-5-values-per-field/m-p/595310#M207180</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-04-25T23:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to get sum of Top 5 values per field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-sum-of-Top-5-values-per-field/m-p/595332#M207194</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/227098"&gt;@ISP8055&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please try this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;YOUR_SEARCH
| sort - Server Load
| streamstats count by Server 
| where count&amp;lt;=3
| stats sum(Load) As Load  by Server&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Sample Search :&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=100
| fields - _time
| eval Server="G".((random() % 5)+1)
| eval Load=random() % 100
| rename comment as "Upto now is for sample data only. Your search logic will start after this"
| sort - Server Load
| streamstats count by Server 
| where count&amp;lt;=3
| stats sum(Load) As Load  by Server&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this will help you.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;Thanks&lt;BR /&gt;KV&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 05:52:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-sum-of-Top-5-values-per-field/m-p/595332#M207194</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2022-04-26T05:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to get sum of Top 5 values per field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-sum-of-Top-5-values-per-field/m-p/595463#M207239</link>
      <description>&lt;P&gt;Sorry, I'm getting no results found using this syntax.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 17:38:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-sum-of-Top-5-values-per-field/m-p/595463#M207239</guid>
      <dc:creator>ISP8055</dc:creator>
      <dc:date>2022-04-26T17:38:49Z</dc:date>
    </item>
  </channel>
</rss>

