<?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 edit my search to sort a count by a field to get the top 3 ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-sort-a-count-by-a-field-to-get-the-top/m-p/218528#M64216</link>
    <description>&lt;P&gt;There may be a typo in my answer (in rex to extract URL), I wasn't sure about the field name. To here is what you should do&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...your current search as you mentioned in question | untable URI IP count | sort 3 -count by URI | xyseries URI IP count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 08 Aug 2016 19:27:52 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-08-08T19:27:52Z</dc:date>
    <item>
      <title>How to edit my search to sort a count by a field to get the top 3 ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-sort-a-count-by-a-field-to-get-the-top/m-p/218525#M64213</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have one that I've worked around until now..... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;The scenario is:&lt;/P&gt;

&lt;P&gt;Row is URI&lt;BR /&gt;
/a&lt;BR /&gt;
/b&lt;BR /&gt;
/c&lt;BR /&gt;
/d&lt;BR /&gt;
/e&lt;BR /&gt;
/f&lt;/P&gt;

&lt;P&gt;Column is IP&lt;BR /&gt;
1.1.1.1   2.2.2.2  3.3.3.3   4.4.4.4   5.5.5.5.&lt;/P&gt;

&lt;P&gt;What I need to do is sort by the count of URI by IP so that I get the top 3.&lt;/P&gt;

&lt;P&gt;I've used addtotals and then sort by the total which works ,but the problem is the chart is already displayed, so while 4.4.4.4 is sorted correctly, 1.1.1.1 has the value of 0 in all its columns because its counts are lower and not included in the top 3, yet the IP is still displayed in the chart&lt;/P&gt;

&lt;P&gt;The search is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-6h host="*beta*" source="/etc/httpd/logs/portal-access_log*" index=main | rex "HTTP.\d.\d.\s+(?&amp;lt; status &amp;gt;\d+)" | search status=404 |rex "(?&amp;lt; ip &amp;gt;\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"|rex "GET\s(?[^\"]+)"|eval URI=if(URI="\"GET",URL,URI)|chart useother=f count as Count by URI ip|addtotals|sort -Total|head 10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is a screenshot (note the first 4 columns)&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/1696i18BC9734EE698A2F/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;How can I get the chart so that the top 3 show by URI AND IP?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 18:49:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-sort-a-count-by-a-field-to-get-the-top/m-p/218525#M64213</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-08T18:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to sort a count by a field to get the top 3 ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-sort-a-count-by-a-field-to-get-the-top/m-p/218526#M64214</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-6h host="beta" source="/etc/httpd/logs/portal-access_log*" index=main | rex "HTTP.\d.\d.\s+(?&amp;lt;status&amp;gt;\d+)" | search status=404 |rex "(?&amp;lt;ip&amp;gt;\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})"|rex "GET\s(?&amp;lt;URL&amp;gt;[^\"]+)"|eval URI=if(URI="\"GET",URL,URI)
| stats count by URI ip | |chart useother=f count as Count by URI ip|addtotals |sort -Total|head 10 | untable URI IP count | sort 3 -count by URI | xyseries URI IP count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Aug 2016 19:02:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-sort-a-count-by-a-field-to-get-the-top/m-p/218526#M64214</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-08-08T19:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to sort a count by a field to get the top 3 ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-sort-a-count-by-a-field-to-get-the-top/m-p/218527#M64215</link>
      <description>&lt;P&gt;Hmmmmm, ended up saying no results found after removing the extra | in front of chart.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 19:24:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-sort-a-count-by-a-field-to-get-the-top/m-p/218527#M64215</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-08T19:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to sort a count by a field to get the top 3 ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-sort-a-count-by-a-field-to-get-the-top/m-p/218528#M64216</link>
      <description>&lt;P&gt;There may be a typo in my answer (in rex to extract URL), I wasn't sure about the field name. To here is what you should do&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...your current search as you mentioned in question | untable URI IP count | sort 3 -count by URI | xyseries URI IP count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Aug 2016 19:27:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-sort-a-count-by-a-field-to-get-the-top/m-p/218528#M64216</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-08-08T19:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to sort a count by a field to get the top 3 ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-sort-a-count-by-a-field-to-get-the-top/m-p/218529#M64217</link>
      <description>&lt;P&gt;That worked!  Many thanks somesoni2!   Gave me some new commands that I'm not aware of &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;   Now to study up on them!&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 19:38:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-sort-a-count-by-a-field-to-get-the-top/m-p/218529#M64217</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-08T19:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to sort a count by a field to get the top 3 ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-sort-a-count-by-a-field-to-get-the-top/m-p/218530#M64218</link>
      <description>&lt;P&gt;On more little snag....  For some reason it is only giving me the top 2.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 19:57:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-sort-a-count-by-a-field-to-get-the-top/m-p/218530#M64218</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-08T19:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to sort a count by a field to get the top 3 ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-sort-a-count-by-a-field-to-get-the-top/m-p/218531#M64219</link>
      <description>&lt;P&gt;Found it!  &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;earliest=-6h host="&lt;EM&gt;beta&lt;/EM&gt;" source="/etc/httpd/logs/portal-access_log*" index=main | rex "HTTP.\d.\d.\s+(?&amp;lt; status &amp;gt;\d+)" | search status=404 |rex "(?&amp;lt; ip &amp;gt;\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})"|rex "GET\s(?&amp;lt; URL &amp;gt;[^\"]+)"|eval URI=if(URI="\"GET",URL,URI)|where ip!="54.174.106.18"|where ip!="54.210.253.21"|where ip!="54.210.253.139"|chart count as Count by URI ip |untable URI ip count | sort 10 -count by URI | xyseries URI ip count&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 20:52:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-sort-a-count-by-a-field-to-get-the-top/m-p/218531#M64219</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2016-08-08T20:52:27Z</dc:date>
    </item>
  </channel>
</rss>

