<?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 use stats command after top command. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-stats-command-after-top-command/m-p/346853#M160677</link>
    <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=cub source=xyz.log
[ index=cub source=xyz.log
| top limit=5 apiName 
| fields apiName ] 
| stats avg(apiTime) min(apiTime) max(apiTime) BY apiName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 15 Jun 2017 23:30:11 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-06-15T23:30:11Z</dc:date>
    <item>
      <title>How to use stats command after top command.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-stats-command-after-top-command/m-p/346851#M160675</link>
      <description>&lt;P&gt;Hi all&lt;BR /&gt;
I am trying to do the following search.&lt;BR /&gt;
 which would result in Top 5 apiname values along with their apitime(avg,min,max) values included but unable to get the list the data. &lt;/P&gt;

&lt;P&gt;index=cub source=xyz.log&lt;BR /&gt;
|top limit=5 apiName&lt;BR /&gt;
|stats avg(apiTime),min(apiTime),max(apiTime) by apiName&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 05:26:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-stats-command-after-top-command/m-p/346851#M160675</guid>
      <dc:creator>rakshithreddy</dc:creator>
      <dc:date>2017-06-15T05:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to use stats command after top command.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-stats-command-after-top-command/m-p/346852#M160676</link>
      <description>&lt;P&gt;After top you only left with 5 records of most occuring apiName, corresponding count and percentage. There is no apiTime field available so the stats fails. Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=cub source=xyz.log
|stats count avg(apiTime),min(apiTime),max(apiTime) by apiName
| eventstats sum(count) as total | eval perc=count*100/total
| sort 5 -count | fields - total
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jun 2017 15:39:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-stats-command-after-top-command/m-p/346852#M160676</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-06-15T15:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to use stats command after top command.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-stats-command-after-top-command/m-p/346853#M160677</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=cub source=xyz.log
[ index=cub source=xyz.log
| top limit=5 apiName 
| fields apiName ] 
| stats avg(apiTime) min(apiTime) max(apiTime) BY apiName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jun 2017 23:30:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-stats-command-after-top-command/m-p/346853#M160677</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-15T23:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to use stats command after top command.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-stats-command-after-top-command/m-p/346854#M160678</link>
      <description>&lt;P&gt;This answer is better; mine is mainly for education because it is more like how you were trying to solve it (but don't use it).&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 23:31:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-stats-command-after-top-command/m-p/346854#M160678</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-15T23:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to use stats command after top command.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-stats-command-after-top-command/m-p/346855#M160679</link>
      <description>&lt;P&gt;Hmmm.  Seems like it would be possible to substitute a tstats command into the subsearch that would make it more efficient than somesoni2's version, solely when there is a high cardinality for apiName and/or a longer time period that makes the stats expensive...&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 03:33:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-stats-command-after-top-command/m-p/346855#M160679</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-06-16T03:33:48Z</dc:date>
    </item>
  </channel>
</rss>

