<?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: Subsearch needed or can't use top :) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33682#M7169</link>
    <description>&lt;P&gt;Right.  In that case use subsearch as Kristian has in his answer.&lt;/P&gt;</description>
    <pubDate>Tue, 14 May 2013 23:48:49 GMT</pubDate>
    <dc:creator>sdaniels</dc:creator>
    <dc:date>2013-05-14T23:48:49Z</dc:date>
    <item>
      <title>Subsearch needed or can't use top :)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33671#M7158</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Given the following access logs generated by the same page:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Input:&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;A href="http://mydomain1.com/q?L=5000"&gt;http://mydomain1.com/q?L=5000&lt;/A&gt; [ Referer header: &lt;A href="http://mydomain2.com/some-page2.html"&gt;http://mydomain2.com/some-page2.html&lt;/A&gt; ]&lt;BR /&gt;&lt;BR /&gt;
&lt;A href="http://mydomain1.com/q?L=6000"&gt;http://mydomain1.com/q?L=6000&lt;/A&gt; [ Referer header: &lt;A href="http://mydomain5.com/some-page5.html"&gt;http://mydomain5.com/some-page5.html&lt;/A&gt; ]&lt;BR /&gt;&lt;BR /&gt;
&lt;A href="http://mydomain1.com/q?L=5500"&gt;http://mydomain1.com/q?L=5500&lt;/A&gt; [ Referer header: &lt;A href="http://mydomain2.com/some-page2.html"&gt;http://mydomain2.com/some-page2.html&lt;/A&gt; ]&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Requirement:&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;
I am trying find average values of L (greater than 1000 and less than 60001) by top 5 referers.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Attempted solutions&lt;/STRONG&gt;:&lt;BR /&gt;&lt;BR /&gt;
I thought about subsearch, but get it to work as expected:&lt;BR /&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype="mysource" L&amp;gt;1000 L&amp;lt;60001 | top 5 referer | timechart avg(L) span=5m by referer
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Would I have to find the top 5 referers in a query, and then use the results of referers from that query as a pivot for another query?! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I wouldn't know how to get started with that one in Splunk.. I was trying to follow this guide &lt;A href="http://www.innovato.com/splunk/SQLSplunk.html"&gt;http://www.innovato.com/splunk/SQLSplunk.html&lt;/A&gt; but no luck &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Any help is appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;
Thank you.&lt;BR /&gt;&lt;BR /&gt;
-Gokce&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2013 19:00:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33671#M7158</guid>
      <dc:creator>gt2013</dc:creator>
      <dc:date>2013-05-14T19:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch needed or can't use top :)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33672#M7159</link>
      <description>&lt;P&gt;Updated:&lt;/P&gt;

&lt;P&gt;What about doing something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... &amp;lt;your search&amp;gt; |bucket _time span=5m | stats avg(L) as myAvg  by referer | sort -myAvg | head 5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That should give you the top 5 referrers based on the average value of 'L'.&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2013 19:08:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33672#M7159</guid>
      <dc:creator>sdaniels</dc:creator>
      <dc:date>2013-05-14T19:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch needed or can't use top :)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33673#M7160</link>
      <description>&lt;P&gt;would the &lt;CODE&gt;head 5&lt;/CODE&gt; ensure that is was the &lt;CODE&gt;top 5&lt;/CODE&gt;? without &lt;CODE&gt;c&lt;/CODE&gt; and &lt;CODE&gt;| sort&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2013 20:34:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33673#M7160</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-05-14T20:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch needed or can't use top :)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33674#M7161</link>
      <description>&lt;P&gt;with a subsearch&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype="mysource" L&amp;gt;1000 L&amp;lt;60001 [search index=myindex sourcetype="mysource" L&amp;gt;1000 L&amp;lt;60001 | top 5 referer | fields + referer]| timechart avg(L) span=5m by referer
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;/Kristian&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2013 20:37:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33674#M7161</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-05-14T20:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch needed or can't use top :)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33675#M7162</link>
      <description>&lt;P&gt;Part 1 of comment (due to 600 char limit):&lt;/P&gt;

&lt;P&gt;While I am trying to find a solution.. I have observed couple of things... Given this query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype="mysource" L&amp;gt;1000 L&amp;lt;60001 | stats count by referer | sort 10 -count | fields referer 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get the expected results; ie Top 10 referers by count, and matching events would be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;113,948 matching events
referer
1   &lt;A href="http://domain1.com/page1.html" target="test_blank"&gt;http://domain1.com/page1.html&lt;/A&gt;
2   &lt;A href="http://domain2.com/page2.html" target="test_blank"&gt;http://domain2.com/page2.html&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 May 2013 21:46:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33675#M7162</guid>
      <dc:creator>gt2013</dc:creator>
      <dc:date>2013-05-14T21:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch needed or can't use top :)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33676#M7163</link>
      <description>&lt;P&gt;Part 2:&lt;BR /&gt;
If I want to use this in a &lt;EM&gt;subsearch&lt;/EM&gt;, then looks like I need to prepend &lt;EM&gt;"search"&lt;/EM&gt; keyword to the query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search index=myindex sourcetype="mysource" L&amp;gt;1000 L&amp;lt;60001 | stats count by referer | sort 10 -count | fields referer
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but then I get a different result set:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;252 matching events
referer
1 &lt;A href="http://someotherdomain1.com" target="test_blank"&gt;http://someotherdomain1.com&lt;/A&gt;
2 &lt;A href="http://somereallyotherdomain1.com" target="test_blank"&gt;http://somereallyotherdomain1.com&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So the &lt;EM&gt;"search"&lt;/EM&gt; keyword in the beginning does not seem correct &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2013 21:47:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33676#M7163</guid>
      <dc:creator>gt2013</dc:creator>
      <dc:date>2013-05-14T21:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch needed or can't use top :)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33677#M7164</link>
      <description>&lt;P&gt;Part 3:&lt;BR /&gt;
And if I execute this subsearch:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype="mysource" [index=myindex sourcetype="mysource" L&amp;gt;1000 L&amp;lt;60001 | stats count by referer | sort 10 -count | fields referer] | timechart avg(L) span=2m by referer
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get an error from Splunk:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Unknown search command 'index'.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any ideas on how to execute this subsearch?&lt;/P&gt;

&lt;P&gt;Thank you for all your help.&lt;BR /&gt;&lt;BR /&gt;
-Gokce&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2013 21:47:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33677#M7164</guid>
      <dc:creator>gt2013</dc:creator>
      <dc:date>2013-05-14T21:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch needed or can't use top :)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33678#M7165</link>
      <description>&lt;P&gt;Kristian - yep i need the sort. I'll update it&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2013 21:57:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33678#M7165</guid>
      <dc:creator>sdaniels</dc:creator>
      <dc:date>2013-05-14T21:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch needed or can't use top :)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33679#M7166</link>
      <description>&lt;P&gt;Thank you for all your answers, this is awesome.&lt;/P&gt;

&lt;P&gt;This is definitely close to what I would like to get, however the query is sorting results by top 5 average values of L and finding the referers.&lt;/P&gt;

&lt;P&gt;How would I get the top 5 referers and then find their average values of L over time? This is why I thought I needed the subsearch.&lt;/P&gt;

&lt;P&gt;Thanks again, I appreciate all your help.&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2013 22:34:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33679#M7166</guid>
      <dc:creator>gt2013</dc:creator>
      <dc:date>2013-05-14T22:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch needed or can't use top :)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33680#M7167</link>
      <description>&lt;P&gt;This is exactly what I tried to, however the subsearch is returning a different result set when ran as a subsearch:&lt;/P&gt;

&lt;P&gt;This query:&lt;BR /&gt;
index=myindex sourcetype="mysource" L&amp;gt;1000 L&amp;lt;60001 | top 5 referer | fields + referer&lt;/P&gt;

&lt;P&gt;is returning different results when ran as (ie with search keyword prepended to it):&lt;BR /&gt;
search index=myindex sourcetype="mysource" L&amp;gt;1000 L&amp;lt;60001 | top 5 referer | fields + referer&lt;/P&gt;

&lt;P&gt;First I thought it's the subsearch maxtime, but when I run it for a short period of time, it's definitely returning different results. Please see 3 part comment above &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thank you for all your help.&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2013 22:38:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33680#M7167</guid>
      <dc:creator>gt2013</dc:creator>
      <dc:date>2013-05-14T22:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch needed or can't use top :)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33681#M7168</link>
      <description>&lt;P&gt;@kristian.kolb, To make you subsearch work shouldnt you use the &lt;STRONG&gt;return&lt;/STRONG&gt; command which will pass values up from the subsearch. &lt;STRONG&gt;index=myindex sourcetype="mysource" [search index=myindex sourcetype="mysource" | where L&amp;gt;1000 and L&amp;lt;6001 | top 5 referer | return referer]| timechart avg(L) span=5m by referer&lt;/STRONG&gt;.  The return command should produce a search base like this &lt;STRONG&gt;index=myindex sourcetype="mysource" AND (referer=&amp;lt;value1&amp;gt; OR referer=&amp;lt;value2&amp;gt; OR referer=&amp;lt;value3&amp;gt; OR referer=&amp;lt;value4&amp;gt; OR referer=&amp;lt;value5&amp;gt;)|...&lt;/STRONG&gt;. You might need another where clause before timechart&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2013 23:39:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33681#M7168</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2013-05-14T23:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch needed or can't use top :)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33682#M7169</link>
      <description>&lt;P&gt;Right.  In that case use subsearch as Kristian has in his answer.&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2013 23:48:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33682#M7169</guid>
      <dc:creator>sdaniels</dc:creator>
      <dc:date>2013-05-14T23:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch needed or can't use top :)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33683#M7170</link>
      <description>&lt;P&gt;Looks like return only returns 1 answer:&lt;/P&gt;

&lt;P&gt;search index=myindex sourcetype="mysource" | where L&amp;gt;1000 and L&amp;lt;60001 | top 5 referer | return referer&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;1   referer="&lt;A href="http://somedomain.com/page1.html"&gt;http://somedomain.com/page1.html&lt;/A&gt;"&lt;/P&gt;

&lt;P&gt;without return:&lt;BR /&gt;
    referer count   percent&lt;BR /&gt;
1   &lt;A href="http://domain1.com/page1.html"&gt;http://domain1.com/page1.html&lt;/A&gt;   14  8.187135&lt;BR /&gt;
2   &lt;A href="http://domain2.com/page2.html"&gt;http://domain2.com/page2.html&lt;/A&gt;   12  7.017544&lt;BR /&gt;
3   &lt;A href="http://domain3.com/page3.html"&gt;http://domain3.com/page3.html&lt;/A&gt;   10  5.847953&lt;BR /&gt;
4   &lt;A href="http://domain4.com/page4.html"&gt;http://domain4.com/page4.html&lt;/A&gt;   7   4.093567&lt;BR /&gt;
5   &lt;A href="http://domain5.com/page5.html"&gt;http://domain5.com/page5.html&lt;/A&gt;...&lt;/P&gt;

&lt;P&gt;I think we are very close.. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I am learning a lot from this exercise.. I didn't even know about return command &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thank you for all your help.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2013 00:32:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33683#M7170</guid>
      <dc:creator>gt2013</dc:creator>
      <dc:date>2013-05-15T00:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch needed or can't use top :)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33684#M7171</link>
      <description>&lt;P&gt;@gt2013: &lt;CODE&gt;search&lt;/CODE&gt; is required for the subsearch to work.&lt;/P&gt;

&lt;P&gt;@bmacias84: No I normally don't use &lt;CODE&gt;return&lt;/CODE&gt; for subsearches. &lt;CODE&gt;fields&lt;/CODE&gt; will normally do quite well (and will produce a set of OR'ed field/value pairs.)&lt;/P&gt;

&lt;P&gt;@gt2013, well, the docs for the return command states that you can/should specify the number of results you want. So, if you want to use &lt;CODE&gt;return&lt;/CODE&gt;, try &lt;CODE&gt;| return 5 referer&lt;/CODE&gt; I guess.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2013 06:17:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-needed-or-can-t-use-top/m-p/33684#M7171</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-05-15T06:17:45Z</dc:date>
    </item>
  </channel>
</rss>

