<?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: Find average when using group by in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Find-average-when-using-group-by/m-p/492569#M137400</link>
    <description>&lt;P&gt;Thanks. I just removed by channel and it worked. I was just overthinking.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Oct 2019 20:10:28 GMT</pubDate>
    <dc:creator>balash1979</dc:creator>
    <dc:date>2019-10-03T20:10:28Z</dc:date>
    <item>
      <title>Find average when using group by</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-average-when-using-group-by/m-p/492567#M137398</link>
      <description>&lt;P&gt;Here is my query &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="search_index"   search processing_service | eval time_in_mins=('metric_value')/60 | stats avg(time_in_mins) by channel
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;By running this query, i get the following results &lt;BR /&gt;
channel1   5.25&lt;BR /&gt;
channel2   6.25&lt;BR /&gt;
channel3   10.25&lt;/P&gt;

&lt;P&gt;Basically, i get output of all the channels and their averages. how can I get only 1 value with the average of all the channel averages ? &lt;BR /&gt;
I would like an output of my query as &lt;/P&gt;

&lt;P&gt;Avg_of_all_channels  7.25&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:22:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-average-when-using-group-by/m-p/492567#M137398</guid>
      <dc:creator>balash1979</dc:creator>
      <dc:date>2020-09-30T02:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: Find average when using group by</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-average-when-using-group-by/m-p/492568#M137399</link>
      <description>&lt;P&gt;@balash1979,&lt;/P&gt;

&lt;P&gt;What do you get after removing the &lt;CODE&gt;by channel&lt;/CODE&gt; from the search ? &lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 14:33:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-average-when-using-group-by/m-p/492568#M137399</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-10-03T14:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Find average when using group by</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-average-when-using-group-by/m-p/492569#M137400</link>
      <description>&lt;P&gt;Thanks. I just removed by channel and it worked. I was just overthinking.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 20:10:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-average-when-using-group-by/m-p/492569#M137400</guid>
      <dc:creator>balash1979</dc:creator>
      <dc:date>2019-10-03T20:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: Find average when using group by</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-average-when-using-group-by/m-p/492570#M137401</link>
      <description>&lt;P&gt;as @renjith.nair stated in the comments, I believe what you're after is simply&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="search_index"   search processing_service | eval time_in_mins=('metric_value')/60 | stats avg(time_in_mins) as all_channel_avg
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which would just output one column named all_channel_avg and one row with the avg.&lt;/P&gt;

&lt;P&gt;if you'd like both the individual channel avg AND the total avg, possibly something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="search_index"   search processing_service | eval time_in_mins=('metric_value')/60 |eventstats avg(time_in_mins) as total_avg| stats values(total_avg) as all_channel_avg avg(time_in_mins) as channel_avg by channel
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;however, you might want to do a count and sum in the stats command and then the eventstats and some eval in order to not run eventstats before stats. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="search_index"   search processing_service | eval time_in_mins=('metric_value')/60| stats  avg(time_in_mins) as channel_avg sum(time_in_mins) as total_mins count as total_count by channel|eventstats sum(total_mins) as total_mins sum(total_count) as total_count|eval all_channel_avg=total_mins/total_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;again, that might actually need some work, as i'm currently really thinking that the math might not be right....&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:28:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-average-when-using-group-by/m-p/492570#M137401</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2020-09-30T02:28:36Z</dc:date>
    </item>
  </channel>
</rss>

