<?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 fetch top 5 rows based on a value in table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-top-5-rows-based-on-a-value-in-table/m-p/490436#M194141</link>
    <description>&lt;P&gt;but that does not valdiate the total count..only of the count is above 200 i need head -5&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jan 2020 18:16:13 GMT</pubDate>
    <dc:creator>ashanka</dc:creator>
    <dc:date>2020-01-23T18:16:13Z</dc:date>
    <item>
      <title>How to fetch top 5 rows based on a value in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-top-5-rows-based-on-a-value-in-table/m-p/490433#M194138</link>
      <description>&lt;P&gt;index= aab sourcetype=topconnections earliest=-10m latest=-5m&lt;BR /&gt;
| table SESSION_AUTH_ID , CONNECTION_COUNT&lt;BR /&gt;
| addcoltotals labelfield=SESSION_AUTH_ID label=TotalCount&lt;/P&gt;

&lt;P&gt;SESSION_AUTH_ID CONNECTION_COUNT&lt;BR /&gt;
a   178&lt;BR /&gt;
b   65&lt;BR /&gt;
v   36&lt;BR /&gt;
d   21&lt;BR /&gt;
e   12&lt;BR /&gt;
f   12&lt;BR /&gt;
g   10&lt;BR /&gt;
h   8&lt;BR /&gt;
h   5&lt;BR /&gt;
f   4&lt;BR /&gt;
f   4&lt;BR /&gt;
l   3&lt;BR /&gt;
o   2&lt;BR /&gt;
z   2&lt;BR /&gt;
TotalCount  201&lt;/P&gt;

&lt;P&gt;how do i get the top 5 rows from table when the total count is greater than 200.&lt;/P&gt;

&lt;P&gt;when the total count reached 200 i need to get the top 5 SESSION_AUTH_ID     and its CONNECTION_COUNT&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:47:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-top-5-rows-based-on-a-value-in-table/m-p/490433#M194138</guid>
      <dc:creator>ashanka</dc:creator>
      <dc:date>2020-09-30T03:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to fetch top 5 rows based on a value in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-top-5-rows-based-on-a-value-in-table/m-p/490434#M194139</link>
      <description>&lt;P&gt;See if this works . Add the following to the end or your search query.&lt;/P&gt;

&lt;P&gt;| head 5&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 22:41:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-top-5-rows-based-on-a-value-in-table/m-p/490434#M194139</guid>
      <dc:creator>dol_splunk_user</dc:creator>
      <dc:date>2020-01-22T22:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to fetch top 5 rows based on a value in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-top-5-rows-based-on-a-value-in-table/m-p/490435#M194140</link>
      <description>&lt;P&gt;Try this. Hope this is what you are looking for&lt;/P&gt;

&lt;P&gt;index= aab sourcetype=topconnections earliest=-10m latest=-5m&lt;BR /&gt;
| table SESSION_AUTH_ID , CONNECTION_COUNT&lt;BR /&gt;
|eventstats sum(CONNECTION_COUNT) as TotalCount&lt;BR /&gt;
|  where TotalCount&amp;gt; 200 &lt;BR /&gt;
|  sort - CONNECTION_COUNT&lt;BR /&gt;
|  head 5&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:47:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-top-5-rows-based-on-a-value-in-table/m-p/490435#M194140</guid>
      <dc:creator>cvsvineeth</dc:creator>
      <dc:date>2020-09-30T03:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to fetch top 5 rows based on a value in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-top-5-rows-based-on-a-value-in-table/m-p/490436#M194141</link>
      <description>&lt;P&gt;but that does not valdiate the total count..only of the count is above 200 i need head -5&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 18:16:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-top-5-rows-based-on-a-value-in-table/m-p/490436#M194141</guid>
      <dc:creator>ashanka</dc:creator>
      <dc:date>2020-01-23T18:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to fetch top 5 rows based on a value in table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-top-5-rows-based-on-a-value-in-table/m-p/490437#M194142</link>
      <description>&lt;P&gt;your sample check:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="SESSION_AUTH_ID,CONNECTION_COUNT
a,178
b,65
v,36
d,21
e,12
f,12
g,10
h,8
h,5
f,4
f,4
l,3
o,2
z,2"
| multikv forceheader=1
| table SESSION_AUTH_ID,CONNECTION_COUNT
| eventstats sum(CONNECTION_COUNT) as total
| stats list(*) as * by total
| eval tmp=mvzip(SESSION_AUTH_ID,CONNECTION_COUNT)
| eval result =if( total &amp;gt; 200, mvindex(tmp,0,4),"the total count is smaller than 200")
| table total result
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;recommend:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index= aab sourcetype=topconnections earliest=-10m latest=-5m
| table SESSION_AUTH_ID , CONNECTION_COUNT
| eventstats sum(CONNECTION_COUNT) as total
| stats list(*) as * by total
| eval tmp=mvzip(SESSION_AUTH_ID,CONNECTION_COUNT)
| eval result =if( total &amp;gt; 200, mvindex(tmp,0,4),"the total count is smaller than 200")
| table total result
| rex field=result "(?&amp;lt;SESSION_AUTH_ID&amp;gt;[^\,]+),(?&amp;lt;CONNECTION_COUNT&amp;gt;.+)"
| table total result SESSION_AUTH_ID CONNECTION_COUNT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi folks. how about this?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 18:46:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-top-5-rows-based-on-a-value-in-table/m-p/490437#M194142</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-23T18:46:44Z</dc:date>
    </item>
  </channel>
</rss>

