<?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 return the 5 most repeat_count values per environment? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-return-the-5-most-repeat-count-values-per-environment/m-p/303652#M91339</link>
    <description>&lt;P&gt;This should do what you're looking for:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=amc environment=* 
| stats count AS repeat_count BY environment nodename 
| sort 0 - environment repeat_count 
| streamstats count AS top_count BY environment 
| where top_count&amp;lt;=5 
| fields environment nodename repeat_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After generating the &lt;CODE&gt;repeat_count&lt;/CODE&gt; value, it sorts all the values within each &lt;CODE&gt;environment&lt;/CODE&gt; category by &lt;CODE&gt;repeat_count&lt;/CODE&gt;. It then uses streamstats to generate a &lt;CODE&gt;top_count&lt;/CODE&gt; value within each environment category. It filters out events with a &lt;CODE&gt;top_count&lt;/CODE&gt; value greater than 5 (preserving only the top 5), and then organizes the fields as you displayed them.&lt;/P&gt;</description>
    <pubDate>Wed, 04 Apr 2018 17:30:58 GMT</pubDate>
    <dc:creator>elliotproebstel</dc:creator>
    <dc:date>2018-04-04T17:30:58Z</dc:date>
    <item>
      <title>How to return the 5 most repeat_count values per environment?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-return-the-5-most-repeat-count-values-per-environment/m-p/303651#M91338</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;need your help&lt;/EM&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=amc| search environment=* |top 5 showperc=f countfield="repeat_count" environment nodename

environment nodename    repeat_count
DR          Hostname1   636
Prod        Hostname2   117
Prod        Hostname3   108
Prod        Hostname4   102
Prod        Hostname5   87
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;who to get top 5 repeat_count host per environment [example show below]&lt;/STRONG&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;environment nodename    repeat_count
DR          Hostname1   636
DR          Hostname12  637
DR          Hostname13  638
DR          Hostname14  639
DR          Hostname15  640
Prod        Hostname21  117
Prod        Hostname22  108
Prod        Hostname23  102
Prod        Hostname24  87
Prod        Hostname25  86
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Apr 2018 17:15:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-return-the-5-most-repeat-count-values-per-environment/m-p/303651#M91338</guid>
      <dc:creator>harsush</dc:creator>
      <dc:date>2018-04-04T17:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to return the 5 most repeat_count values per environment?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-return-the-5-most-repeat-count-values-per-environment/m-p/303652#M91339</link>
      <description>&lt;P&gt;This should do what you're looking for:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=amc environment=* 
| stats count AS repeat_count BY environment nodename 
| sort 0 - environment repeat_count 
| streamstats count AS top_count BY environment 
| where top_count&amp;lt;=5 
| fields environment nodename repeat_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After generating the &lt;CODE&gt;repeat_count&lt;/CODE&gt; value, it sorts all the values within each &lt;CODE&gt;environment&lt;/CODE&gt; category by &lt;CODE&gt;repeat_count&lt;/CODE&gt;. It then uses streamstats to generate a &lt;CODE&gt;top_count&lt;/CODE&gt; value within each environment category. It filters out events with a &lt;CODE&gt;top_count&lt;/CODE&gt; value greater than 5 (preserving only the top 5), and then organizes the fields as you displayed them.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 17:30:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-return-the-5-most-repeat-count-values-per-environment/m-p/303652#M91339</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-04-04T17:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to return the 5 most repeat_count values per environment?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-return-the-5-most-repeat-count-values-per-environment/m-p/303653#M91340</link>
      <description>&lt;P&gt;repeat_count is a field which has count of number of alerts&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 17:36:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-return-the-5-most-repeat-count-values-per-environment/m-p/303653#M91340</guid>
      <dc:creator>harsush</dc:creator>
      <dc:date>2018-04-04T17:36:50Z</dc:date>
    </item>
  </channel>
</rss>

