<?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 do this search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-this-search/m-p/41873#M9702</link>
    <description>&lt;P&gt;This is a very good example of a situation where a &lt;EM&gt;subsearch&lt;/EM&gt; can be used. Use your first search to single out the hosts with the most events, then feed those hosts into your outer search and generate the statistics:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* [my search | stats count by src | sort - count | head 10] | stats count,values(_raw) by src
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;More information on subsearches can be found in the docs:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.splunk.com/base/Documentation/4.2.2/User/Subsearchtutorial"&gt;http://www.splunk.com/base/Documentation/4.2.2/User/Subsearchtutorial&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.splunk.com/base/Documentation/latest/User/HowSubsearchesWork"&gt;http://www.splunk.com/base/Documentation/latest/User/HowSubsearchesWork&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jul 2011 04:12:08 GMT</pubDate>
    <dc:creator>Ayn</dc:creator>
    <dc:date>2011-07-13T04:12:08Z</dc:date>
    <item>
      <title>How to do this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-this-search/m-p/41872#M9701</link>
      <description>&lt;P&gt;Hi~there,&lt;/P&gt;

&lt;P&gt;The first search is quite simple, just extract top 10 stats count by src, so i use&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my search | stats count by src | sort - count | head 10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but now i wanna use this top 10 src to separately list its top 50 events, how can I do this? Thanks in advance.&lt;/P&gt;

&lt;P&gt;just like follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;src,     count,   event
---      -----    -----
x.x.x.1   500     1.the first   raw event
                  2.the second  raw event
                  3.the third   raw event
                  .
                  .
                  50.the 50th   raw event
x.x.x.2   200     1.the first   raw event
                  2.the second  raw event
                  3.the third   raw event
                  .
                  .
                  50.the 50th   raw event
.
.
.
x.x.x.10  300     1.the first   raw event
                  2.the second  raw event
                  3.the third   raw event
                  .
                  .
                  50.the 50th   raw event
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jul 2011 02:05:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-this-search/m-p/41872#M9701</guid>
      <dc:creator>hjwang</dc:creator>
      <dc:date>2011-07-13T02:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to do this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-this-search/m-p/41873#M9702</link>
      <description>&lt;P&gt;This is a very good example of a situation where a &lt;EM&gt;subsearch&lt;/EM&gt; can be used. Use your first search to single out the hosts with the most events, then feed those hosts into your outer search and generate the statistics:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* [my search | stats count by src | sort - count | head 10] | stats count,values(_raw) by src
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;More information on subsearches can be found in the docs:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.splunk.com/base/Documentation/4.2.2/User/Subsearchtutorial"&gt;http://www.splunk.com/base/Documentation/4.2.2/User/Subsearchtutorial&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.splunk.com/base/Documentation/latest/User/HowSubsearchesWork"&gt;http://www.splunk.com/base/Documentation/latest/User/HowSubsearchesWork&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2011 04:12:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-this-search/m-p/41873#M9702</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2011-07-13T04:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to do this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-this-search/m-p/41874#M9703</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;... | eventstats count by src | dedup 50 src sortby count,src | streamstats global=t current=t dc(src) as rank | where rank &amp;lt;= 10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then, if you want to to display with nulls in your data, you can add:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | dedup keepevents=t src,count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But that is purely for display purposes as it founds up your data. This will be rather more efficient than using a subsearch in your case, as it uses a single pass over the data rather than two passes.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2011 04:30:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-this-search/m-p/41874#M9703</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-07-13T04:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to do this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-this-search/m-p/41875#M9704</link>
      <description>&lt;P&gt;here, i have doubt that if using values(_raw) how can i extract only head 50 raw event ? thanks&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2011 07:29:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-this-search/m-p/41875#M9704</guid>
      <dc:creator>hjwang</dc:creator>
      <dc:date>2011-07-13T07:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to do this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-this-search/m-p/41876#M9705</link>
      <description>&lt;P&gt;streamstats means "Adds summary statistics to all search results in a streaming manner". but i don't really understand about streaming manner and its difference with eventstats.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2011 08:55:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-this-search/m-p/41876#M9705</guid>
      <dc:creator>hjwang</dc:creator>
      <dc:date>2011-07-13T08:55:28Z</dc:date>
    </item>
  </channel>
</rss>

