<?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 get max hits for a field ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142873#M39671</link>
    <description>&lt;P&gt;Yes I did try that before posting the comment. It only gives me top 5 person for everyday. It gives me&lt;/P&gt;

&lt;P&gt;|client|User|count|&lt;BR /&gt;
|A| 1|100|&lt;BR /&gt;
|A|2|90|&lt;BR /&gt;
|A| 3|80|&lt;BR /&gt;
|A| 4|70|&lt;BR /&gt;
|A|5|50|&lt;/P&gt;

&lt;P&gt;It doesnt give the stats for other clients B,C and D&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jun 2015 20:58:47 GMT</pubDate>
    <dc:creator>sp1711</dc:creator>
    <dc:date>2015-06-04T20:58:47Z</dc:date>
    <item>
      <title>How to get max hits for a field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142869#M39667</link>
      <description>&lt;P&gt;So, I have a search with a regex that has pulled 2 different fields- lets say user and client.&lt;/P&gt;

&lt;P&gt;the url is something like,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{base_url}/user/{user_1}/hello.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This user field can hold 100's of values - user_1, user_2, user_3........... &lt;/P&gt;

&lt;P&gt;I want to know how many times each "user" is hit on a daily basis for different clients(there are 4 clients). And I &lt;STRONG&gt;only&lt;/STRONG&gt; want the users that have max hits everyday (top 5 ).&lt;/P&gt;

&lt;P&gt;So, for everyday, for every client, top 5 users with the count ofcourse.&lt;BR /&gt;
how do I do that.?&lt;/P&gt;

&lt;P&gt;I tried this,&lt;/P&gt;

&lt;P&gt;My_search|bucket span=1d _time | stats count by _time client user | head 5 &lt;/P&gt;

&lt;P&gt;This gives me a messed up output. Any ideas??&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 20:10:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142869#M39667</guid>
      <dc:creator>sp1711</dc:creator>
      <dc:date>2020-09-28T20:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max hits for a field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142870#M39668</link>
      <description>&lt;P&gt;Hi sp1711,&lt;/P&gt;

&lt;P&gt;The obvious search is something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;My_search | timechart values(client) AS client count by user limit=5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but this shows the top 5 globally, not the top 5 per day. &lt;BR /&gt;
The problem with "per-day" is that every day could have 5 completely different top user and thus for a month, you may need 150 series.&lt;/P&gt;

&lt;P&gt;If you really want to calculate per day, it's something more like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;My_search
| bin span=1d _time
| stats count by _time client user
| sort - _time count
| dedup 5 _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this will give you, per-day, the top 5 client, user ,count groups. &lt;BR /&gt;
Add this to graph / chart it: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| timechart span=1d values(client) AS client sum(count) by user limit=1000
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 20:33:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142870#M39668</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-06-04T20:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max hits for a field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142871#M39669</link>
      <description>&lt;P&gt;Hi MuS,&lt;/P&gt;

&lt;P&gt;That really got me close to what I want. I tried your second search&lt;BR /&gt;&lt;BR /&gt;
    My_search&lt;BR /&gt;
     | bin span=1d _time&lt;BR /&gt;
     | stats count by _time client user&lt;BR /&gt;
     | sort - _time count&lt;BR /&gt;
     | dedup 5 _time&lt;/P&gt;

&lt;P&gt;This gives me the top 5 users everyday along with which client it belongs. It doesn't give me top 5 users for every client. How do I tweak this for the expected result?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 20:46:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142871#M39669</guid>
      <dc:creator>sp1711</dc:creator>
      <dc:date>2015-06-04T20:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max hits for a field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142872#M39670</link>
      <description>&lt;P&gt;Just change the &lt;CODE&gt;stats&lt;/CODE&gt; like &lt;CODE&gt;| stats count by client user _time&lt;/CODE&gt; so it matches your needs. The first field after the &lt;CODE&gt;by&lt;/CODE&gt; statement is the the sorting one. &lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 20:50:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142872#M39670</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-06-04T20:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max hits for a field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142873#M39671</link>
      <description>&lt;P&gt;Yes I did try that before posting the comment. It only gives me top 5 person for everyday. It gives me&lt;/P&gt;

&lt;P&gt;|client|User|count|&lt;BR /&gt;
|A| 1|100|&lt;BR /&gt;
|A|2|90|&lt;BR /&gt;
|A| 3|80|&lt;BR /&gt;
|A| 4|70|&lt;BR /&gt;
|A|5|50|&lt;/P&gt;

&lt;P&gt;It doesnt give the stats for other clients B,C and D&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 20:58:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142873#M39671</guid>
      <dc:creator>sp1711</dc:creator>
      <dc:date>2015-06-04T20:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max hits for a field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142874#M39672</link>
      <description>&lt;P&gt;Ok, Instead of  &lt;CODE&gt;dedup 5 _time&lt;/CODE&gt; I did &lt;CODE&gt;dedup 5 client&lt;/CODE&gt; this does the job. But I'm getting the data only for today even if I select a date range of a month in the search. Thats weird.!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 21:18:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142874#M39672</guid>
      <dc:creator>sp1711</dc:creator>
      <dc:date>2015-06-04T21:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max hits for a field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142875#M39673</link>
      <description>&lt;P&gt;Use the job inspector to verify what happens with the time range in the base search&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 21:21:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142875#M39673</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-06-04T21:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max hits for a field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142876#M39674</link>
      <description>&lt;P&gt;So I checked that ,&lt;BR /&gt;
The component, command.dedup has input of 10,000 and output of 10.&lt;/P&gt;

&lt;P&gt;Which makes sense because whatever date range I choose I only get 2 days worth of result (top 5 each), which makes it 10. Is that any issue with limit?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 22:04:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142876#M39674</guid>
      <dc:creator>sp1711</dc:creator>
      <dc:date>2015-06-04T22:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max hits for a field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142877#M39675</link>
      <description>&lt;P&gt;what is the exact search command you're using now?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 22:15:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142877#M39675</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-06-04T22:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max hits for a field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142878#M39676</link>
      <description>&lt;P&gt;This is the search &lt;CODE&gt;index="abc" tag=def sourcetype=access_combined "hello"|fields correlation_id|join correlation_id[search index="abc" tag=something sourcetype=access_combined "whatsup"]|rex "(?i)/users/(?P[^/]+)" | rex field=req_host "^(?[^.]*)"&lt;/CODE&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 22:22:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142878#M39676</guid>
      <dc:creator>sp1711</dc:creator>
      <dc:date>2015-06-04T22:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max hits for a field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142879#M39677</link>
      <description>&lt;P&gt;The formatting is screwed up!&lt;BR /&gt;&lt;BR /&gt;
One of the regex has user in it and another has client. &lt;/P&gt;

&lt;P&gt;It eats up some parts when I try to format.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 22:24:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142879#M39677</guid>
      <dc:creator>sp1711</dc:creator>
      <dc:date>2015-06-04T22:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max hits for a field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142880#M39678</link>
      <description>&lt;P&gt;ohhh you're using a subsearch....I'm no friend of them at all &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; Because you hit limits with them and they are not really fast. This is not related to this question, but look at this answer &lt;A href="http://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html"&gt;http://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html&lt;/A&gt; and try to adapt your search to a single stats search.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 22:30:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142880#M39678</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-06-04T22:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to get max hits for a field ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142881#M39679</link>
      <description>&lt;P&gt;Thanks for the direction. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 22:33:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-max-hits-for-a-field/m-p/142881#M39679</guid>
      <dc:creator>sp1711</dc:creator>
      <dc:date>2015-06-04T22:33:41Z</dc:date>
    </item>
  </channel>
</rss>

