<?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 inline stats without subsearch in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/inline-stats-without-subsearch/m-p/111985#M29403</link>
    <description>&lt;P&gt;This is a recurring problem for me in SPL.  I want to assign some stats command results to a variable name and pop that into a table with the rest of the results.  For instance, if my data look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;user    visits   action    url             
steve   3        blocked   &lt;A href="https://community.splunk.com/www.porn.com" target="test_blank"&gt;www.porn.com&lt;/A&gt; 
steve   5        blocked   &lt;A href="https://community.splunk.com/www.porn.com" target="test_blank"&gt;www.porn.com&lt;/A&gt; 
steve   23       blocked   &lt;A href="https://community.splunk.com/www.porn.com" target="test_blank"&gt;www.porn.com&lt;/A&gt; 
steve   1        blocked   &lt;A href="https://community.splunk.com/www.porn.com" target="test_blank"&gt;www.porn.com&lt;/A&gt; 
jack    4        allowed   &lt;A href="https://community.splunk.com/www.gov.gov" target="test_blank"&gt;www.gov.gov&lt;/A&gt;
jack    3        allowed   &lt;A href="https://community.splunk.com/www.gov.gov" target="test_blank"&gt;www.gov.gov&lt;/A&gt;
jack    1        allowed   &lt;A href="https://community.splunk.com/www.gov.gov" target="test_blank"&gt;www.gov.gov&lt;/A&gt;
jack    5        allowed   &lt;A href="https://community.splunk.com/www.gov.gov" target="test_blank"&gt;www.gov.gov&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And all I want to do is list the max(visits) or avg(visits) or stdev(visits) (or all 3) for each combination of user, url and action, I want to do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=proxy sourcetype=proxy earliest=-7d@d | stats avg(visits) as AVG by user | table user url AVG action
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But that won't work because stats now only makes AVG and user available for the next pipe (in other words, url &amp;amp; action will be blank in the table).  So, when I need all previous info + some sort of new calculated info available for the next section, I have started using eval, but eval doesn't have any stats capabilities.  So what I'm looking for is something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=proxy sourcetype=proxy earliest=-7d@d | eval AVG = avg(visits) by user | table user url AVG action
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But obviously, there is no such thing as eval x = avg().  Is there any way to get stats from some data without nuking the data (without using a subsearch?)&lt;/P&gt;

&lt;P&gt;Subsearch is fine when you have tiny little data sets, but it's not feasible for this use case.&lt;/P&gt;</description>
    <pubDate>Thu, 19 Jun 2014 17:08:26 GMT</pubDate>
    <dc:creator>proletariat99</dc:creator>
    <dc:date>2014-06-19T17:08:26Z</dc:date>
    <item>
      <title>inline stats without subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/inline-stats-without-subsearch/m-p/111985#M29403</link>
      <description>&lt;P&gt;This is a recurring problem for me in SPL.  I want to assign some stats command results to a variable name and pop that into a table with the rest of the results.  For instance, if my data look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;user    visits   action    url             
steve   3        blocked   &lt;A href="https://community.splunk.com/www.porn.com" target="test_blank"&gt;www.porn.com&lt;/A&gt; 
steve   5        blocked   &lt;A href="https://community.splunk.com/www.porn.com" target="test_blank"&gt;www.porn.com&lt;/A&gt; 
steve   23       blocked   &lt;A href="https://community.splunk.com/www.porn.com" target="test_blank"&gt;www.porn.com&lt;/A&gt; 
steve   1        blocked   &lt;A href="https://community.splunk.com/www.porn.com" target="test_blank"&gt;www.porn.com&lt;/A&gt; 
jack    4        allowed   &lt;A href="https://community.splunk.com/www.gov.gov" target="test_blank"&gt;www.gov.gov&lt;/A&gt;
jack    3        allowed   &lt;A href="https://community.splunk.com/www.gov.gov" target="test_blank"&gt;www.gov.gov&lt;/A&gt;
jack    1        allowed   &lt;A href="https://community.splunk.com/www.gov.gov" target="test_blank"&gt;www.gov.gov&lt;/A&gt;
jack    5        allowed   &lt;A href="https://community.splunk.com/www.gov.gov" target="test_blank"&gt;www.gov.gov&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And all I want to do is list the max(visits) or avg(visits) or stdev(visits) (or all 3) for each combination of user, url and action, I want to do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=proxy sourcetype=proxy earliest=-7d@d | stats avg(visits) as AVG by user | table user url AVG action
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But that won't work because stats now only makes AVG and user available for the next pipe (in other words, url &amp;amp; action will be blank in the table).  So, when I need all previous info + some sort of new calculated info available for the next section, I have started using eval, but eval doesn't have any stats capabilities.  So what I'm looking for is something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=proxy sourcetype=proxy earliest=-7d@d | eval AVG = avg(visits) by user | table user url AVG action
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But obviously, there is no such thing as eval x = avg().  Is there any way to get stats from some data without nuking the data (without using a subsearch?)&lt;/P&gt;

&lt;P&gt;Subsearch is fine when you have tiny little data sets, but it's not feasible for this use case.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2014 17:08:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/inline-stats-without-subsearch/m-p/111985#M29403</guid>
      <dc:creator>proletariat99</dc:creator>
      <dc:date>2014-06-19T17:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: inline stats without subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/inline-stats-without-subsearch/m-p/111986#M29404</link>
      <description>&lt;P&gt;You can do exactly what you want by using &lt;CODE&gt;eventstats&lt;/CODE&gt; instead of &lt;CODE&gt;stats&lt;/CODE&gt;. &lt;CODE&gt;eventstats&lt;/CODE&gt; writes its results as a field in the original event rather than "consuming" its input and only leave its calculated fields as output. &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1/SearchReference/Eventstats"&gt;http://docs.splunk.com/Documentation/Splunk/6.1/SearchReference/Eventstats&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2014 17:56:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/inline-stats-without-subsearch/m-p/111986#M29404</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2014-06-19T17:56:00Z</dc:date>
    </item>
  </channel>
</rss>

