<?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 of my search result for past 7 days. Also how can i make my result to display in timechart for 7 days? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-the-average-of-my-search-result-for-past-7-days/m-p/228488#M67573</link>
    <description>&lt;P&gt;Try this - Here I'm just replacing &lt;CODE&gt;stats sum(b)&lt;/CODE&gt; with &lt;CODE&gt;timechart span=1d sum(b)&lt;/CODE&gt;.  When run over a 7 day timerange, instead of one row in your search result you'll get 7 (or more generally 8, since there's part of today as well as part of 8 days ago in a 7 day timerange)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field_id="X" | eval b=len(_raw) | timechart span=1d sum(b) as b | eval mb=round(b/1024/1024,2) | eval gb=round(b/1024/1024/1024,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;UPDATE:&lt;BR /&gt;
(sorry for forgetting the 'avg per day' bit) -  you then want to calculate what the average is per day,  but first of all I would make sure that your timerange is very precise about what days are being searched.     The default "Last 7 days" timerange is from   -7d@h to now.   However this will include today up to the current time, which is bad,  and also a little slice of the day that was exactly one week ago.   Instead you should use the "Advanced" part of the time range picker to run this timerange:   &lt;/P&gt;

&lt;P&gt;earliest:   -7d@d&lt;BR /&gt;
latest:    @d&lt;/P&gt;

&lt;P&gt;That will run precisely a 7 day timerange. &lt;/P&gt;

&lt;P&gt;Then you can calculate the average fo those just by tacking on an extra &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats avg(mb) as MB  avg(gb) as GB
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 03 Oct 2016 19:48:52 GMT</pubDate>
    <dc:creator>sideview</dc:creator>
    <dc:date>2016-10-03T19:48:52Z</dc:date>
    <item>
      <title>how to calculate the average of my search result for past 7 days. Also how can i make my result to display in timechart for 7 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-the-average-of-my-search-result-for-past-7-days/m-p/228487#M67572</link>
      <description>&lt;P&gt;I have a search as follows &lt;/P&gt;

&lt;P&gt;field_id="X" | eval b=len(_raw) | stats sum(b) as b | eval mb=round(b/1024/1024,2) | eval gb=round(b/1024/1024/1024,2)&lt;/P&gt;

&lt;P&gt;Which displays the result in bytes,megabytes and gigabytes for a particullar search.&lt;/P&gt;

&lt;P&gt;Now how can i make to display the timechart count for each day and get the average count for the data?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:16:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-the-average-of-my-search-result-for-past-7-days/m-p/228487#M67572</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2020-09-29T11:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the average of my search result for past 7 days. Also how can i make my result to display in timechart for 7 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-the-average-of-my-search-result-for-past-7-days/m-p/228488#M67573</link>
      <description>&lt;P&gt;Try this - Here I'm just replacing &lt;CODE&gt;stats sum(b)&lt;/CODE&gt; with &lt;CODE&gt;timechart span=1d sum(b)&lt;/CODE&gt;.  When run over a 7 day timerange, instead of one row in your search result you'll get 7 (or more generally 8, since there's part of today as well as part of 8 days ago in a 7 day timerange)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field_id="X" | eval b=len(_raw) | timechart span=1d sum(b) as b | eval mb=round(b/1024/1024,2) | eval gb=round(b/1024/1024/1024,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;UPDATE:&lt;BR /&gt;
(sorry for forgetting the 'avg per day' bit) -  you then want to calculate what the average is per day,  but first of all I would make sure that your timerange is very precise about what days are being searched.     The default "Last 7 days" timerange is from   -7d@h to now.   However this will include today up to the current time, which is bad,  and also a little slice of the day that was exactly one week ago.   Instead you should use the "Advanced" part of the time range picker to run this timerange:   &lt;/P&gt;

&lt;P&gt;earliest:   -7d@d&lt;BR /&gt;
latest:    @d&lt;/P&gt;

&lt;P&gt;That will run precisely a 7 day timerange. &lt;/P&gt;

&lt;P&gt;Then you can calculate the average fo those just by tacking on an extra &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats avg(mb) as MB  avg(gb) as GB
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Oct 2016 19:48:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-the-average-of-my-search-result-for-past-7-days/m-p/228488#M67573</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2016-10-03T19:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the average of my search result for past 7 days. Also how can i make my result to display in timechart for 7 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-the-average-of-my-search-result-for-past-7-days/m-p/228489#M67574</link>
      <description>&lt;P&gt;And How to calculate average(mb) for the past 7 days?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2016 19:58:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-the-average-of-my-search-result-for-past-7-days/m-p/228489#M67574</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2016-10-03T19:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the average of my search result for past 7 days. Also how can i make my result to display in timechart for 7 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-the-average-of-my-search-result-for-past-7-days/m-p/228490#M67575</link>
      <description>&lt;P&gt;Just add " &lt;CODE&gt;| eventstats avg(gb) as Avg&lt;/CODE&gt; " at the end for the average for that time period.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2016 20:00:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-the-average-of-my-search-result-for-past-7-days/m-p/228490#M67575</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-10-03T20:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate the average of my search result for past 7 days. Also how can i make my result to display in timechart for 7 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-the-average-of-my-search-result-for-past-7-days/m-p/228491#M67576</link>
      <description>&lt;P&gt;D'oh - thanks somesoni2.   I neglected to follow through all the way and write up how to do the avg-per-day.  I've updated the answer. &lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2016 20:07:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-calculate-the-average-of-my-search-result-for-past-7-days/m-p/228491#M67576</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2016-10-03T20:07:13Z</dc:date>
    </item>
  </channel>
</rss>

