<?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: How to edit my search to get the top 3 apps by total_byte and group all other app results as &amp;quot;Other&amp;quot;? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-top-3-apps-by-total-byte-and/m-p/276702#M83473</link>
    <description>&lt;P&gt;The top command works based on number of events (not on magnitude of a field value) hence that didn't work. Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=* app="*"
 | chart sum(sentbyte) as sum_send, sum(rcvdbyte) as sum_rcv by app
 | addtotals fieldname=total_byte sum_*
 | sort - total_byte
 | eval rank=1 | accum rank | appendpipe [where rank&amp;gt;3 | stats sum(total_byte) as total_byte | eval app="Others" | eval rank=3] 
 | where rank &amp;lt;4 | fields - rank
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 09 Feb 2016 20:54:13 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-02-09T20:54:13Z</dc:date>
    <item>
      <title>How to edit my search to get the top 3 apps by total_byte and group all other app results as "Other"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-top-3-apps-by-total-byte-and/m-p/276699#M83470</link>
      <description>&lt;P&gt;Hi Splukers,&lt;/P&gt;

&lt;P&gt;I cannot get a search to produce what I want. Please help me.&lt;BR /&gt;
I tried the following search and got results.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* app="*"
| chart sum(sentbyte) as sum_send, sum(rcvdbyte) as sum_rcv by app
| addtotals fieldname=total_byte sum_*
| sort - total_byte
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Results&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;app             sum_send    sum_rcv  total_byte
HTTP.BROWSER    7775148     50982187    58757335
Yum             300136      13395774    13695910
SSH             5558054  6727574     12285628
Wget            1029059  10632394   11661453
DNS          9008       3125787  3134795
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Next I want to get top 3 apps and others list by total_byte like the following.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;app          total_byte
HTTP.BROWSER    58757335
Yum             13695910
SSH          12285628
Other           14796248
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried this search, but I lost the app name..&lt;BR /&gt;
And I also tried &lt;CODE&gt;top total_bytes by app&lt;/CODE&gt; commands etc..but no good.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* app="*"
| chart sum(sentbyte) as sum_send, sum(rcvdbyte) as sum_rcv by app
| addtotals fieldname=total_byte sum_*
| sort - total_byte
| top limit=3 total_byte showcount=f showperc=f useother=t
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So, how do I get what I want?&lt;BR /&gt;
Thank you very much.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 11:20:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-top-3-apps-by-total-byte-and/m-p/276699#M83470</guid>
      <dc:creator>sunrise</dc:creator>
      <dc:date>2016-02-09T11:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to get the top 3 apps by total_byte and group all other app results as "Other"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-top-3-apps-by-total-byte-and/m-p/276700#M83471</link>
      <description>&lt;P&gt;you use ' head ' command like that :&lt;/P&gt;

&lt;P&gt;index=* app="&lt;EM&gt;"&lt;BR /&gt;
| chart sum(sentbyte) as sum_send, sum(rcvdbyte) as sum_rcv by app&lt;BR /&gt;
| addtotals fieldname=total_byte sum_&lt;/EM&gt;&lt;BR /&gt;
| sort - total_byte&lt;BR /&gt;
| head 3&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:42:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-top-3-apps-by-total-byte-and/m-p/276700#M83471</guid>
      <dc:creator>fdi01</dc:creator>
      <dc:date>2020-09-29T08:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to get the top 3 apps by total_byte and group all other app results as "Other"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-top-3-apps-by-total-byte-and/m-p/276701#M83472</link>
      <description>&lt;P&gt;This might look a bit overcomplicated and i'm sure there's an easier way, but I didn't manage to get top working as you would expect so this is my approach using sort and streamstats instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index= app=""
| chart sum(sentbyte) as sum_send, sum(rcvdbyte) as sum_rcv by app
| eval total_byte = sum_send + sum_rcv
| sort num(total_byte)
| streamstats count, sum(total_byte) as sum_total_byte
| eval total_byte = if(count &amp;gt;= 3, total_byte, sum_total_byte)
| eval app = if(count &amp;gt;= 3, app, "OTHER")
| fields app, total_byte
| sort 4 -num(total_byte)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note this is hardcoded to work with the top 3 only.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 12:11:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-top-3-apps-by-total-byte-and/m-p/276701#M83472</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-02-09T12:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to get the top 3 apps by total_byte and group all other app results as "Other"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-top-3-apps-by-total-byte-and/m-p/276702#M83473</link>
      <description>&lt;P&gt;The top command works based on number of events (not on magnitude of a field value) hence that didn't work. Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=* app="*"
 | chart sum(sentbyte) as sum_send, sum(rcvdbyte) as sum_rcv by app
 | addtotals fieldname=total_byte sum_*
 | sort - total_byte
 | eval rank=1 | accum rank | appendpipe [where rank&amp;gt;3 | stats sum(total_byte) as total_byte | eval app="Others" | eval rank=3] 
 | where rank &amp;lt;4 | fields - rank
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Feb 2016 20:54:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-top-3-apps-by-total-byte-and/m-p/276702#M83473</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-09T20:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to get the top 3 apps by total_byte and group all other app results as "Other"?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-top-3-apps-by-total-byte-and/m-p/276703#M83474</link>
      <description>&lt;P&gt;Thank you, somesoni2.&lt;BR /&gt;
Great! A series of searches from "rank" field to "appendpipe" is a very convenient way.&lt;BR /&gt;
I like it.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2016 01:17:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-get-the-top-3-apps-by-total-byte-and/m-p/276703#M83474</guid>
      <dc:creator>sunrise</dc:creator>
      <dc:date>2016-02-10T01:17:41Z</dc:date>
    </item>
  </channel>
</rss>

