<?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 can I limit the results of a stats values() function? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238796#M70956</link>
    <description>&lt;P&gt;Thanks, the search does exactly what I needed.&lt;/P&gt;</description>
    <pubDate>Tue, 10 Oct 2017 11:15:34 GMT</pubDate>
    <dc:creator>CSmoke</dc:creator>
    <dc:date>2017-10-10T11:15:34Z</dc:date>
    <item>
      <title>How can I limit the results of a stats values() function?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238791#M70951</link>
      <description>&lt;P&gt;I want to list about 10 unique values of a certain field in a stats command. I cannot figure out how to do this. I figured stats values() would work, and it does... but I'm getting hundred of thousands of results. I only want the first ten!&lt;/P&gt;

&lt;P&gt;Of course, a top command or simple head command won't work because I need the values of a field, keyed off of another field.&lt;/P&gt;

&lt;P&gt;Example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* | stats values(IPs) count by hostname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want the first ten IP values for each hostname. NOT all (hundreds) of them! Imagine a crazy dhcp scenario. I'm also open to other ways of displaying the data.&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2016 17:13:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238791#M70951</guid>
      <dc:creator>thisissplunk</dc:creator>
      <dc:date>2016-05-04T17:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: How can I limit the results of a stats values() function?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238792#M70952</link>
      <description>&lt;P&gt;I've figured it out. You need to use a mvindex command to only show say, 1 through 10 of the values() results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats values(IP) AS unique_ip_list_sample dc(IP) AS actual_unique_ip_count count as events by hostname 
| eval unique_ip_list_sample=mvindex(unique_ip_value_sample, 0, 10)
| sort -events
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 May 2016 17:33:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238792#M70952</guid>
      <dc:creator>thisissplunk</dc:creator>
      <dc:date>2016-05-04T17:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: How can I limit the results of a stats values() function?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238793#M70953</link>
      <description>&lt;P&gt;Try this&lt;BR /&gt;
    index=* | stats values(IPs) a ip by hostname | mvexpand ip | streamstats count by host | where count&amp;lt;=10 | stats values(ip) as IPs by host&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2016 17:34:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238793#M70953</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-05-04T17:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can I limit the results of a stats values() function?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238794#M70954</link>
      <description>&lt;P&gt;That's what I was thinking initially, but I don't want to actually filter any events out, which is what the "where" does.&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2016 17:36:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238794#M70954</guid>
      <dc:creator>thisissplunk</dc:creator>
      <dc:date>2016-05-04T17:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: How can I limit the results of a stats values() function?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238795#M70955</link>
      <description>&lt;P&gt;If you have multiple fields that you want to chop (i.e. to show a sample across all) you can also use something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats values(*) as *
| foreach * [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=mvindex('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',0,10)]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jul 2016 19:05:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238795#M70955</guid>
      <dc:creator>pj</dc:creator>
      <dc:date>2016-07-08T19:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I limit the results of a stats values() function?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238796#M70956</link>
      <description>&lt;P&gt;Thanks, the search does exactly what I needed.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 11:15:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238796#M70956</guid>
      <dc:creator>CSmoke</dc:creator>
      <dc:date>2017-10-10T11:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can I limit the results of a stats values() function?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238797#M70957</link>
      <description>&lt;P&gt;That's clean!  Here's a small enhancement:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| foreach * [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=if(mvcount('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')&amp;gt;10, mvappend(mvindex('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',0,9),"..."), '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This will display the first 10 values and if there are more than that it will display a "..." making it clear that the list was truncated.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2017 02:40:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238797#M70957</guid>
      <dc:creator>benton</dc:creator>
      <dc:date>2017-11-01T02:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can I limit the results of a stats values() function?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238798#M70958</link>
      <description>&lt;P&gt;Great solution.  I was able to get my top 10 bandwidth users by business location and URL after a few modifications.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 19:59:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/238798#M70958</guid>
      <dc:creator>sjbriggs</dc:creator>
      <dc:date>2019-04-12T19:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can I limit the results of a stats values() function?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/658031#M227293</link>
      <description>&lt;P&gt;Excellent Job!!!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2023 16:56:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-limit-the-results-of-a-stats-values-function/m-p/658031#M227293</guid>
      <dc:creator>kartikaykv1</dc:creator>
      <dc:date>2023-09-19T16:56:23Z</dc:date>
    </item>
  </channel>
</rss>

