<?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 sort by field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-by-field/m-p/405251#M117145</link>
    <description>&lt;P&gt;Hi @jackpal,&lt;/P&gt;

&lt;P&gt;Try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=os sourcetype=top host=hostname |fields USER,pctCPU,COMMAND|sort pctCPU desc|head 5| chart sum(pctCPU) as CPU_USAGE by USER,COMMAND
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will sort based on cpu usage not on the sum . If you need to sort on sum of cpu usage of a user then , try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    index=os sourcetype=top host=hostname |stats sum(pctCPU) as CPU_USAGE by USER,COMMAND
    |sort CPU_USAGE desc|head 5
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 27 Jun 2018 15:55:39 GMT</pubDate>
    <dc:creator>renjith_nair</dc:creator>
    <dc:date>2018-06-27T15:55:39Z</dc:date>
    <item>
      <title>How to sort by field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-by-field/m-p/405250#M117144</link>
      <description>&lt;P&gt;I am trying to get the highest used process percentage by user, however, I am unable to sort by the field I want to.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=os sourcetype=top host=hostname
| chart sum(pctCPU) as CPU_USAGE by USER,COMMAND
| sort sum(pctCPU) desc 
| head 5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This produces a table but I'd like the chart to only show the top 5 users and the commands they are running sorted by their CPU_USAGE&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 15:08:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-by-field/m-p/405250#M117144</guid>
      <dc:creator>jackpal</dc:creator>
      <dc:date>2018-06-27T15:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort by field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-by-field/m-p/405251#M117145</link>
      <description>&lt;P&gt;Hi @jackpal,&lt;/P&gt;

&lt;P&gt;Try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=os sourcetype=top host=hostname |fields USER,pctCPU,COMMAND|sort pctCPU desc|head 5| chart sum(pctCPU) as CPU_USAGE by USER,COMMAND
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will sort based on cpu usage not on the sum . If you need to sort on sum of cpu usage of a user then , try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    index=os sourcetype=top host=hostname |stats sum(pctCPU) as CPU_USAGE by USER,COMMAND
    |sort CPU_USAGE desc|head 5
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jun 2018 15:55:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-by-field/m-p/405251#M117145</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-06-27T15:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort by field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-by-field/m-p/405252#M117146</link>
      <description>&lt;P&gt;Does this do it for you?:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=os sourcetype=top host=hostname
| stats sum(pctCPU) as CPU_USAGE by USER,COMMAND
| sort - CPU_USAGE
| head 5
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jun 2018 16:04:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-by-field/m-p/405252#M117146</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2018-06-27T16:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort by field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sort-by-field/m-p/405253#M117147</link>
      <description>&lt;P&gt;Thanks to all who responded.  &lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 17:39:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sort-by-field/m-p/405253#M117147</guid>
      <dc:creator>jackpal</dc:creator>
      <dc:date>2018-06-27T17:39:54Z</dc:date>
    </item>
  </channel>
</rss>

