<?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 sort after limit row? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/sort-after-limit-row/m-p/193788#M55850</link>
    <description>&lt;P&gt;Hi:&lt;/P&gt;

&lt;P&gt;I'hope sort after limit row, i try head or sort limit or top...but fail, what can i do?&lt;BR /&gt;
   Thank you&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=xxx |eval bandwidth=rcvdbyte+sentbyte | eval bandwidth(MB) = round(bandwidth/1024/1024,2) | stats list(dstip) as dstip values(app) as app values(hostname) as hostname sum(bandwidth(MB)) as bandwidth(MB) by srcip|  table srcip,dstip,app,hostname bandwidth(MB)|sort bandwidth(MB) desc 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;now:&lt;/P&gt;

&lt;P&gt;srcip     dstip ...   bandwidth(MB)&lt;BR /&gt;
1.1.1.1   2.2.2.2      5&lt;BR /&gt;
          3.3.3.3      5&lt;BR /&gt;
          4.4.4.4      5&lt;BR /&gt;
          ....&lt;BR /&gt;
          10.10.10.10&lt;/P&gt;

&lt;P&gt;hope modify to dstip limit 3:&lt;/P&gt;

&lt;P&gt;srcip     dstip ...   bandwidth(MB)&lt;BR /&gt;
1.1.1.1   2.2.2.2      5&lt;BR /&gt;
          3.3.3.3      5&lt;BR /&gt;
          4.4.4.4      5&lt;/P&gt;</description>
    <pubDate>Wed, 19 Mar 2014 05:12:26 GMT</pubDate>
    <dc:creator>chengyu</dc:creator>
    <dc:date>2014-03-19T05:12:26Z</dc:date>
    <item>
      <title>sort after limit row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-after-limit-row/m-p/193788#M55850</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;

&lt;P&gt;I'hope sort after limit row, i try head or sort limit or top...but fail, what can i do?&lt;BR /&gt;
   Thank you&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=xxx |eval bandwidth=rcvdbyte+sentbyte | eval bandwidth(MB) = round(bandwidth/1024/1024,2) | stats list(dstip) as dstip values(app) as app values(hostname) as hostname sum(bandwidth(MB)) as bandwidth(MB) by srcip|  table srcip,dstip,app,hostname bandwidth(MB)|sort bandwidth(MB) desc 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;now:&lt;/P&gt;

&lt;P&gt;srcip     dstip ...   bandwidth(MB)&lt;BR /&gt;
1.1.1.1   2.2.2.2      5&lt;BR /&gt;
          3.3.3.3      5&lt;BR /&gt;
          4.4.4.4      5&lt;BR /&gt;
          ....&lt;BR /&gt;
          10.10.10.10&lt;/P&gt;

&lt;P&gt;hope modify to dstip limit 3:&lt;/P&gt;

&lt;P&gt;srcip     dstip ...   bandwidth(MB)&lt;BR /&gt;
1.1.1.1   2.2.2.2      5&lt;BR /&gt;
          3.3.3.3      5&lt;BR /&gt;
          4.4.4.4      5&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2014 05:12:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-after-limit-row/m-p/193788#M55850</guid>
      <dc:creator>chengyu</dc:creator>
      <dc:date>2014-03-19T05:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: sort after limit row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-after-limit-row/m-p/193789#M55851</link>
      <description>&lt;P&gt;I am not sure exactly what you want here, but you have some errors in your search. First &lt;CODE&gt;(&lt;/CODE&gt; is not a valid character in a field name, unless you enclose it in quotation marks (sometimes double quotes and sometimes single quotes). So I suggest that you use a different field name like &lt;CODE&gt;bandwidthMB&lt;/CODE&gt; to avoid this problem.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=xxx 
|eval bandwidth=rcvdbyte+sentbyte 
| eval bandwidthMB = round(bandwidth/1024/1024,2) 
| stats list(dstip) as dstip values(app) as app values(hostname) as hostname sum(bandwidthMB) as bandwidthMB by srcip
| sort  10 -bandwidthMB
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;By adding the &lt;CODE&gt;10&lt;/CODE&gt; into the &lt;CODE&gt;sort&lt;/CODE&gt; command, you will only see the top 10 values of bandwidthMB&lt;/P&gt;

&lt;P&gt;If you only want to see the top 3 values of &lt;CODE&gt;dstip&lt;/CODE&gt;, you can do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=xxx 
| eval bandwidthMB=round((rcvdbyte+sentbyte )/1024/1024,2) 
| stats count sum(bandwidthMB) as bandwidthMB by dstip app hostname srcip
| sort srcip -count
| stats list(dstip) as dstip values(app) as app values(hostname) as hostname sum(bandwidthMB) as bandwidthMB by srcip
| eval dstipList = mvjoin(dstip,";")
| eval dstipList = replace(dstipList,"^(.+?;.+?;.+?);.*","\1")
| eval dstip=split(dstipList,";")
| fields - dstipList
| sort 10 -bandwidthMB
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Mar 2014 07:38:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-after-limit-row/m-p/193789#M55851</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2014-03-19T07:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: sort after limit row?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sort-after-limit-row/m-p/193790#M55852</link>
      <description>&lt;P&gt;Thank you so much.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2014 08:31:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sort-after-limit-row/m-p/193790#M55852</guid>
      <dc:creator>chengyu</dc:creator>
      <dc:date>2014-03-19T08:31:49Z</dc:date>
    </item>
  </channel>
</rss>

