<?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: Keep Greatest 5 Counts by Date in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322034#M96215</link>
    <description>&lt;P&gt;I should have thought of that. Thanks! &lt;/P&gt;</description>
    <pubDate>Tue, 30 May 2017 18:09:47 GMT</pubDate>
    <dc:creator>ErikaE</dc:creator>
    <dc:date>2017-05-30T18:09:47Z</dc:date>
    <item>
      <title>Keep Greatest 5 Counts by Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322026#M96207</link>
      <description>&lt;P&gt;I'm counting exceptions over a 24 hour period. My search looks like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=exceptionsindex 
| bin _time span=24h
| stats sum(Exception) as TotalE by Area, _time 
| sort by _time -TotalE
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The output of this search is ~40 events for each day, one for each Area, with a sum of TotalE. &lt;/P&gt;

&lt;P&gt;What I'd like to be able to do is keep only the top 5 offending areas per day. Ideally something like | head 5 TotalE by _time , but head doesn't accept arguments like that. &lt;/P&gt;

&lt;P&gt;Thoughts? &lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 13:40:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322026#M96207</guid>
      <dc:creator>ErikaE</dc:creator>
      <dc:date>2017-05-30T13:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: Keep Greatest 5 Counts by Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322027#M96208</link>
      <description>&lt;P&gt;&lt;STRONG&gt;EDITED:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;add &lt;CODE&gt;|streamstats count by _time |search count&amp;lt;6&lt;/CODE&gt;&lt;BR /&gt;
and see if that works.&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 13:43:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322027#M96208</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-05-30T13:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Keep Greatest 5 Counts by Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322028#M96209</link>
      <description>&lt;P&gt;Does not appear to work. After running streamstats, I get a table with count=1 for each row. &lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 13:59:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322028#M96209</guid>
      <dc:creator>ErikaE</dc:creator>
      <dc:date>2017-05-30T13:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: Keep Greatest 5 Counts by Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322029#M96210</link>
      <description>&lt;P&gt;try taking _time out of the streamstats. i thought with that being binned by every 24 hours, the streamstats would work.&lt;/P&gt;

&lt;P&gt;if that doesn't work, can i get a sample of what the data looks like?&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 14:01:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322029#M96210</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-05-30T14:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Keep Greatest 5 Counts by Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322030#M96211</link>
      <description>&lt;P&gt;It had the same output. &lt;/P&gt;

&lt;P&gt;The data table looks like this:  &lt;/P&gt;

&lt;P&gt;I'd like to "keep" the 5 areas with the Highest TotalE by date. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Area TotalE _time
3  15  t1 
5  14  t1
6  12  t1
2  11  t1
4  10  t1
9  9   t1
1  8   t1 
3  17  t2 
5  13  t2
6  11  t2 
2  10  t2 
4  9   t2 
1  8   t2 
8  4   t2 
7  2   t2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 May 2017 14:18:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322030#M96211</guid>
      <dc:creator>ErikaE</dc:creator>
      <dc:date>2017-05-30T14:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: Keep Greatest 5 Counts by Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322031#M96212</link>
      <description>&lt;P&gt;@cmerriman - You left the &lt;CODE&gt;Area&lt;/CODE&gt; in, so all counts will be 1.  Also, just on general principles, always rename &lt;CODE&gt;count&lt;/CODE&gt; to something else.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| streamstats count as daycount by _time | search daycount&amp;lt;6
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 May 2017 14:23:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322031#M96212</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-30T14:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Keep Greatest 5 Counts by Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322032#M96213</link>
      <description>&lt;P&gt;sorry, look at my edited syntax in original answer. i misunderstood question. with provided data, using this syntax:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults|eval data=" Area=3 TotalE=15 _time=t1, Area=5 TotalE=14 _time=t1, Area=6 TotalE=12 _time=t1, Area=2 TotalE=11 _time=t1, Area=4 TotalE=10 _time=t1, Area=9 TotalE=9 _time=t1, Area=1 TotalE=8 _time=t1, Area=3 TotalE=17 _time=t2, Area=5 TotalE=13 _time=t2, Area=6 TotalE=11 _time=t2, Area=2 TotalE=10 _time=t2, Area=4 TotalE=9 _time=t2, Area=1 TotalE=8 _time=t2, Area=8 TotalE=4 _time=t2, Area=7 TotalE=2 _time=t2"|makemv data delim=","|mvexpand data| rename data as _raw|kv|fields Area TotalE time|fields - _raw _time|sort  time  -TotalE|streamstats count by time|search count&amp;lt;6
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;my results are:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Area  TotalE  time    count 3 15  t1  1&lt;BR /&gt;
5 14  t1  2 6 12  t1  3 2 11  t1  4&lt;BR /&gt;
4 10  t1  5 3 17  t2  1 5 13  t2  2&lt;BR /&gt;
6 11  t2  3 2 10  t2  4 4 9   t2  5&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 30 May 2017 14:29:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322032#M96213</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-05-30T14:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: Keep Greatest 5 Counts by Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322033#M96214</link>
      <description>&lt;P&gt;Like this, with the &lt;CODE&gt;dedup&lt;/CODE&gt; command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=exceptionsindex 
| bin _time span=24h
| stats sum(Exception) AS TotalE BY Area _time 
| sort _time -TotalE
| dedup 5 Date
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 May 2017 16:10:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322033#M96214</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-30T16:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Keep Greatest 5 Counts by Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322034#M96215</link>
      <description>&lt;P&gt;I should have thought of that. Thanks! &lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 18:09:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Keep-Greatest-5-Counts-by-Date/m-p/322034#M96215</guid>
      <dc:creator>ErikaE</dc:creator>
      <dc:date>2017-05-30T18:09:47Z</dc:date>
    </item>
  </channel>
</rss>

