<?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: Summary Index - To calculate weekly average in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Summary-Index-To-calculate-weekly-average/m-p/661391#M228349</link>
    <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was running stats again to capture count which was already present in the data along with hour as mentioned by you&lt;/P&gt;&lt;P&gt;Here is final query :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=summary_index_1d "value=Summary_test" app_name=abc HTTP_STATUS_CODE=2xx
| eval current_day = strftime(now(), "%A") 
| eval log_day = strftime(_time, "%A") 
| eval day=strftime(_time, "%d")| eval dayOfWeek = strftime(_time, "%u") | where dayOfWeek &amp;gt;=1 AND dayOfWeek &amp;lt;= 5
| stats avg(count_value) by log_day,hour,day&lt;/LI-CODE&gt;&lt;P&gt;Let me know if any other changes are required on query which can improve its performance.&amp;nbsp;&lt;BR /&gt;Thanks Again.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Oct 2023 14:24:18 GMT</pubDate>
    <dc:creator>Tester237</dc:creator>
    <dc:date>2023-10-19T14:24:18Z</dc:date>
    <item>
      <title>Summary Index - To calculate weekly average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Summary-Index-To-calculate-weekly-average/m-p/661350#M228327</link>
      <description>&lt;P&gt;Hi Team,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using summary index for below requirement :&lt;BR /&gt;1. Store daily counts of HTTP_Status_Code per hour for each of the application (app_name) on to daily summary index&lt;BR /&gt;2. Once in a week, calculate the average for each app_name by hour, HTTP_STATUS_CODE for the stored values in daily summary index.&amp;nbsp;&lt;BR /&gt;3. This average values will be showed in dashboard widget.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I'm trying to calculate avg for the stored values, it isn't working. Below are the steps I'm following:&lt;/P&gt;&lt;P&gt;1. Pushing &lt;STRONG&gt;HTTP_Status_Code, _time,hour, day, app_name, count&lt;/STRONG&gt; along with value "&lt;STRONG&gt;Summary_test&lt;/STRONG&gt;" (for ease of filtering) to daily index named "&lt;STRONG&gt;summary_index_1d&lt;/STRONG&gt;". Note : &lt;EM&gt;app_name&lt;/EM&gt; is a extracted field. There are 25+ different values&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="index" 
| fields HTTP_STATUS_CODE,app_name 
| eval HTTP_STATUS_CODE=case(like(HTTP_STATUS_CODE, "2__"),"2xx",like(HTTP_STATUS_CODE, "4__"),"4xx",like(HTTP_STATUS_CODE, "5__"),"5xx")
| eval hour=strftime(_time, "%H")
| eval day=strftime(_time, "%A")
| bin _time span=1d
| stats count by HTTP_STATUS_CODE,_time,hour,day,app_name
| eval value="Summary_Test" | collect index=summary_index_1d &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Retrieve data from summary index. its showing up the data pushed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=summary_index_1d "value=Summary_Test"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;3. Now I want to calculate the average for previous 2 or 4 weekday data stored in summary index. I'm using below as reference&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Enterprise/How-to-Build-Average-of-Last-4-Monday-Current-day-vs-Today-in-a/m-p/657868/highlight/true#M17385" target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Splunk-Enterprise/How-to-Build-Average-of-Last-4-Monday-Current-day-vs-Today-in-a/m-p/657868/highlight/true#M17385&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Trying to perform avg on summary index stored values. But this fails

index=summary_index_1d "value=Summary_Test" app_name=abc HTTP_STATUS_CODE=2xx
| eval current_day = strftime(now(), "%A") 
| eval log_day = strftime(_time, "%A") 
| eval hour=strftime(_time, "%H")
| eval day=strftime(_time, "%d")| eval dayOfWeek = strftime(_time, "%u") | where dayOfWeek &amp;gt;=1 AND dayOfWeek &amp;lt;= 5
| stats count as value by hour log_day day  | sort log_day, hour | stats avg(value) as average by log_day,hour&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I guess the "hour" in the query is creating conflict. I tried without it and also by changing the values, but not returning expected result. When the same query is used on main index, it works perfectly fine for my requirement. But when used on summary index, its not able to calculate the average.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;This works fine for the requirement. But when same is applied on "Summary index", it fails

index=index app_name=abc 
| eval HTTP_STATUS_CODE=case(like(status, "2__"),"2xx") 
| eval current_day = strftime(now(), "%A") 
| eval log_day = strftime(_time, "%A") 
| eval hour=strftime(_time, "%H")
| eval day=strftime(_time, "%d")| eval dayOfWeek = strftime(_time, "%u") | where dayOfWeek &amp;gt;=1 AND dayOfWeek &amp;lt;= 5
| stats count as value by hour log_day day  | sort log_day, hour | stats avg(value) as average by log_day,hour&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Can you please help me understand what's wrong with query used on summary index ?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&lt;A href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901" target="_blank" rel="noopener"&gt;@yuanliu&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231989"&gt;@smurf&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 11:25:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Summary-Index-To-calculate-weekly-average/m-p/661350#M228327</guid>
      <dc:creator>Tester237</dc:creator>
      <dc:date>2023-10-19T11:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Summary Index - To calculate weekly average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Summary-Index-To-calculate-weekly-average/m-p/661357#M228333</link>
      <description>&lt;P&gt;Perhaps it is this line?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval hour=strftime(_time, "%H")&lt;/LI-CODE&gt;&lt;P&gt;The _time value here will be the time for the start of the day when the summary index was updated i.e. the hour will always be 00&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 11:55:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Summary-Index-To-calculate-weekly-average/m-p/661357#M228333</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-10-19T11:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: Summary Index - To calculate weekly average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Summary-Index-To-calculate-weekly-average/m-p/661373#M228341</link>
      <description>&lt;P&gt;Yes. This is the one. In results, just 00 is being listed in hour column.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;how can this be resolved to achieve results similar to main index ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 13:10:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Summary-Index-To-calculate-weekly-average/m-p/661373#M228341</guid>
      <dc:creator>Tester237</dc:creator>
      <dc:date>2023-10-19T13:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Summary Index - To calculate weekly average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Summary-Index-To-calculate-weekly-average/m-p/661375#M228343</link>
      <description>&lt;P&gt;Try removing the line - hour should already be coming through from the summary index&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 13:41:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Summary-Index-To-calculate-weekly-average/m-p/661375#M228343</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-10-19T13:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Summary Index - To calculate weekly average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Summary-Index-To-calculate-weekly-average/m-p/661391#M228349</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was running stats again to capture count which was already present in the data along with hour as mentioned by you&lt;/P&gt;&lt;P&gt;Here is final query :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=summary_index_1d "value=Summary_test" app_name=abc HTTP_STATUS_CODE=2xx
| eval current_day = strftime(now(), "%A") 
| eval log_day = strftime(_time, "%A") 
| eval day=strftime(_time, "%d")| eval dayOfWeek = strftime(_time, "%u") | where dayOfWeek &amp;gt;=1 AND dayOfWeek &amp;lt;= 5
| stats avg(count_value) by log_day,hour,day&lt;/LI-CODE&gt;&lt;P&gt;Let me know if any other changes are required on query which can improve its performance.&amp;nbsp;&lt;BR /&gt;Thanks Again.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 14:24:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Summary-Index-To-calculate-weekly-average/m-p/661391#M228349</guid>
      <dc:creator>Tester237</dc:creator>
      <dc:date>2023-10-19T14:24:18Z</dc:date>
    </item>
  </channel>
</rss>

