<?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 calculate the average based on fields. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-based-on-fields/m-p/47557#M11352</link>
    <description>&lt;P&gt;Strange. I did the same before but couldn't get the answer. I guess I mistyped something.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Nov 2012 16:26:42 GMT</pubDate>
    <dc:creator>theouhuios</dc:creator>
    <dc:date>2012-11-28T16:26:42Z</dc:date>
    <item>
      <title>How to calculate the average based on fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-based-on-fields/m-p/47554#M11349</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;I think this should be simple enough but somehow I am not able to understand how to approach it.&lt;BR /&gt;
Here is the search which I am using&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="xxxx" record.eventType="create"|stats count by record.affectedCI
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and the data looks ;like. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;record.affectedCI   count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;1   LT95DB10    1&lt;BR /&gt;
2   SNMX2646005T    1&lt;BR /&gt;
3   SNMX2649003N    1&lt;BR /&gt;
4   SNMX265100A8    1&lt;BR /&gt;
5   SNUSE717N4A3    1&lt;BR /&gt;
6   SNUSE722N6PM    1&lt;/P&gt;

&lt;P&gt;What I need to know is to find the average of count over all affected CI's. I did use the stats avr() but somehow that isn't giving me the output which I wanted. This shouldn't be difficult,just that I am not able to think on how to approach it now &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;

&lt;P&gt;theou&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2012 16:12:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-based-on-fields/m-p/47554#M11349</guid>
      <dc:creator>theouhuios</dc:creator>
      <dc:date>2012-11-28T16:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the average based on fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-based-on-fields/m-p/47555#M11350</link>
      <description>&lt;P&gt;Add this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eventstats avg(count) as avg_count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Nov 2012 16:21:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-based-on-fields/m-p/47555#M11350</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2012-11-28T16:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the average based on fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-based-on-fields/m-p/47556#M11351</link>
      <description>&lt;P&gt;if you want an average of all the counts you already calculated from the first search :&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype="xxxx" record.eventType="create"|stats count by record.affectedCI | stats avg(count)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2012 16:21:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-based-on-fields/m-p/47556#M11351</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2012-11-28T16:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the average based on fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-based-on-fields/m-p/47557#M11352</link>
      <description>&lt;P&gt;Strange. I did the same before but couldn't get the answer. I guess I mistyped something.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2012 16:26:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-based-on-fields/m-p/47557#M11352</guid>
      <dc:creator>theouhuios</dc:creator>
      <dc:date>2012-11-28T16:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the average based on fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-based-on-fields/m-p/566976#M197582</link>
      <description>&lt;P&gt;Hello Sir,&lt;/P&gt;&lt;P&gt;I tried following your post and tried to fetch average number of errors during 09/7/21 12:00:00:000 AM to 09/14/21 12:00:00:000 AM.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* &amp;lt;search condition&amp;gt;|stats count by error | stats avg(count) by error&lt;/LI-CODE&gt;&lt;P&gt;I got two columns: error and avg(count). However, I am unable to comprehend how the values were calculated in second column. I tried taking the error counts for each day from 09/7 to 09/13, and calculated the average,&amp;nbsp; the result did not match with the result obtained from the search query.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thus, need your help to understand how the data was calculated and the steps to correct the query.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 13:47:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-based-on-fields/m-p/566976#M197582</guid>
      <dc:creator>Taruchit</dc:creator>
      <dc:date>2021-09-14T13:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the average based on fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-based-on-fields/m-p/682049#M233042</link>
      <description>&lt;P&gt;Curious as to why stats has to be ran twice.&amp;nbsp; Even using table before stats doesn't work to get the proper average.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 20:38:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-the-average-based-on-fields/m-p/682049#M233042</guid>
      <dc:creator>jviray</dc:creator>
      <dc:date>2024-03-26T20:38:56Z</dc:date>
    </item>
  </channel>
</rss>

