<?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: Sorting the stats values results by count, and include count in results in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sorting-the-stats-values-results-by-count-and-include-count-in/m-p/199562#M57785</link>
    <description>&lt;P&gt;Keep the &lt;CODE&gt;values(cs_User_Agent_)&lt;/CODE&gt; untouched. That way you get the distinct count and the values, sort by distinct count, throw away the distinct count.&lt;/P&gt;</description>
    <pubDate>Tue, 17 Jun 2014 15:56:31 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-06-17T15:56:31Z</dc:date>
    <item>
      <title>Sorting the stats values results by count, and include count in results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-the-stats-values-results-by-count-and-include-count-in/m-p/199557#M57780</link>
      <description>&lt;P&gt;I am trying to get a search result that shows a single IP associated with all of its user agents, but I would like the IP's sorted by the overall amount of hits rather than sorted by numerical order. I would also like to be able to see the count of hits in the end result as well. Thanks in advance!&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;My current search:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index="logs" source="mywebsite.com" | stats  values(cs_User_Agent_) as cs_User_Agent_ by c_ip&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Right now it results:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;IP: 11.00.00.00&lt;BR /&gt;&lt;BR /&gt;
User Agent: 1. Mozilla/5.0...&lt;BR /&gt;
            2. Mozilaa/4.0...&lt;/P&gt;

&lt;P&gt;IP: 22.00.00.00&lt;BR /&gt;&lt;BR /&gt;
User Agent: 1. Mozilla/5.0...&lt;/P&gt;

&lt;P&gt;IP: 33.00.00.00&lt;BR /&gt;&lt;BR /&gt;
User Agent: 1. Mozilla/5.0...&lt;BR /&gt;
            2. Mozilaa/4.0...&lt;BR /&gt;
            3. Mozilla/5.0...&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;I am looking to get results like:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;IP: 64.00.00.00 - Count: 13451&lt;BR /&gt;&lt;BR /&gt;
User Agent: 1. Mozilla/5.0...&lt;BR /&gt;
            2. Mozilaa/4.0...&lt;/P&gt;

&lt;P&gt;IP: 109.00.00.00 - Count: 636&lt;BR /&gt;&lt;BR /&gt;
User Agent: 1. Mozilla/5.0...&lt;/P&gt;

&lt;P&gt;IP: 72.00.00.00 - Count: 122&lt;BR /&gt;&lt;BR /&gt;
User Agent: 1. Mozilla/5.0...&lt;BR /&gt;
            2. Mozilaa/4.0...&lt;BR /&gt;
            3. Mozilla/5.0...&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jun 2014 15:18:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-the-stats-values-results-by-count-and-include-count-in/m-p/199557#M57780</guid>
      <dc:creator>soundchaos</dc:creator>
      <dc:date>2014-06-17T15:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the stats values results by count, and include count in results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-the-stats-values-results-by-count-and-include-count-in/m-p/199558#M57781</link>
      <description>&lt;P&gt;Try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="logs" source="mywebsite.com" | stats count values(cs_User_Agent_) as cs_User_Agent_ by c_ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You'll get three fields - the IP, the count per IP, and the user agents.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jun 2014 15:26:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-the-stats-values-results-by-count-and-include-count-in/m-p/199558#M57781</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-06-17T15:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the stats values results by count, and include count in results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-the-stats-values-results-by-count-and-include-count-in/m-p/199559#M57782</link>
      <description>&lt;P&gt;Thanks! That was way easier than everything I have been trying for the last hour... Would you also have any ideas on how I might sort these results based on how many user agents each IP has, without changing the format of the results? I thought something like | sort -mvcount(cs_User_Agent_) might work, but it does not.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:52:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-the-stats-values-results-by-count-and-include-count-in/m-p/199559#M57782</guid>
      <dc:creator>soundchaos</dc:creator>
      <dc:date>2020-09-28T16:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the stats values results by count, and include count in results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-the-stats-values-results-by-count-and-include-count-in/m-p/199560#M57783</link>
      <description>&lt;P&gt;You can add &lt;CODE&gt;dc(cs_User_Agent_) as dc&lt;/CODE&gt; to the &lt;CODE&gt;stats&lt;/CODE&gt; and run &lt;CODE&gt;| sort - dc | fields - dc&lt;/CODE&gt; at the end.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jun 2014 15:44:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-the-stats-values-results-by-count-and-include-count-in/m-p/199560#M57783</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-06-17T15:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the stats values results by count, and include count in results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-the-stats-values-results-by-count-and-include-count-in/m-p/199561#M57784</link>
      <description>&lt;P&gt;If I am doing it right, that lists just the number of agents used, instead of each individual agent? I was hoping to be able to sort exactly like this, except for showing the full text of each user agent, rather than just the number of how many. Sorry that I am using the comment for an entirely different question &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jun 2014 15:54:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-the-stats-values-results-by-count-and-include-count-in/m-p/199561#M57784</guid>
      <dc:creator>soundchaos</dc:creator>
      <dc:date>2014-06-17T15:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting the stats values results by count, and include count in results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-the-stats-values-results-by-count-and-include-count-in/m-p/199562#M57785</link>
      <description>&lt;P&gt;Keep the &lt;CODE&gt;values(cs_User_Agent_)&lt;/CODE&gt; untouched. That way you get the distinct count and the values, sort by distinct count, throw away the distinct count.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jun 2014 15:56:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-the-stats-values-results-by-count-and-include-count-in/m-p/199562#M57785</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-06-17T15:56:31Z</dc:date>
    </item>
  </channel>
</rss>

