<?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 display count from last week and avg from last month on one timechart in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502365#M139844</link>
    <description>&lt;P&gt;Thanks, but it doesn't work correctly. Displays only week_count result,  but mon_avg_count is empty. If change function from avg to count for (eval(if(last_mon_flag=1,_raw,""))) I receive the same result as for count(eval(if(last_week_flag=1,_raw,""))). &lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 05:28:09 GMT</pubDate>
    <dc:creator>slipinski</dc:creator>
    <dc:date>2020-09-30T05:28:09Z</dc:date>
    <item>
      <title>How to display count from last week and avg from last month on one timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502361#M139840</link>
      <description>&lt;P&gt;I'm trying to plot count of errors from last week per day and daily average value from month. The result from query below gives me only result from Monday (other dayweeks are missing). What did I wrong?&lt;BR /&gt;
avg(count)  DailyCount  Dayweek&lt;BR /&gt;
6903.6          3730                    1 - Mon&lt;/P&gt;

&lt;P&gt;index="abc"   sourcetype=alarms_log  earliest=-30d@d latest=@d&lt;BR /&gt;
| bucket _time span=1day&lt;BR /&gt;
| stats  count by _time | stats avg(count)&lt;BR /&gt;
| join &lt;BR /&gt;
    [search index="abc"  sourcetype=alarms_log earliest=-7d@d latest=-1d@d&lt;BR /&gt;
    | timechart span=1d count as DailyCount&lt;BR /&gt;
    | eval Dayweek=strftime(_time,"%w - %a") ]&lt;/P&gt;

&lt;P&gt;regards,&lt;BR /&gt;
Szymon&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:30:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502361#M139840</guid>
      <dc:creator>slipinski</dc:creator>
      <dc:date>2020-09-30T05:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to display count from last week and avg from last month on one timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502362#M139841</link>
      <description>&lt;P&gt;&lt;CODE&gt;join&lt;/CODE&gt; needs &lt;CODE&gt;field-name&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;reference: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Join"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Join&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 10:11:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502362#M139841</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-05-18T10:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to display count from last week and avg from last month on one timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502363#M139842</link>
      <description>&lt;P&gt;Thanks. This below gives me cycles per a weekday.  Could you point me how to make 30 daily average as a reference point to daily data? I got now:&lt;/P&gt;

&lt;P&gt;Dayweek AvgPerDayWeek   DailyCount&lt;BR /&gt;
1 - Mon 10402.75    3730&lt;BR /&gt;
2 - Tue 9209.75 3237&lt;BR /&gt;
3 - Wed 1073    3194&lt;BR /&gt;
4 - Thu 3688.75 13892&lt;/P&gt;

&lt;P&gt;and would like to have:&lt;BR /&gt;
Format&lt;BR /&gt;
Preview&lt;BR /&gt;
Dayweek AvgPerDayWeek   DailyCount&lt;BR /&gt;
1 - Mon 10340.32    3730&lt;BR /&gt;
2 - Tue 10340.32    3237&lt;BR /&gt;
3 - Wed 10340.32    3194&lt;BR /&gt;
4 - Thu 10340.32    13892&lt;/P&gt;

&lt;P&gt;Maybe subsearch together with eventstats command will be more useful?&lt;/P&gt;

&lt;P&gt;index="abc" sourcetype=alarms_log earliest=-30d@d latest=@d&lt;BR /&gt;
| timechart count span=1d  AS dailycount &lt;BR /&gt;
| eval Dayweek=strftime(_time,"%w - %a")&lt;BR /&gt;
| stats avg(dailycount) AS AvgPerDayWeek by Dayweek&lt;BR /&gt;
| join Dayweek&lt;BR /&gt;
    [search index="abc" sourcetype=alarms_log earliest=-7d@d latest=-1d@d &lt;BR /&gt;
    | timechart span=1d count as DailyCount&lt;BR /&gt;
    | eval Dayweek=strftime(_time,"%w - %a") ]&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:30:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502363#M139842</guid>
      <dc:creator>slipinski</dc:creator>
      <dc:date>2020-09-30T05:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to display count from last week and avg from last month on one timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502364#M139843</link>
      <description>&lt;P&gt;Don't use join, you will hit limits if the time window gets big enough and your granularity gets too small. Use some conditional logic instead&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="abc" sourcetype=alarms_log earliest=-30d@d latest=@d
| bucket _time span=1day
| eval one_week_ago=now()-604800
| eval one_mon_ago=now()-2592000
| eval last_week_flag=if(_time&amp;gt;one_week_ago,1,0)
| eval last_mon_flag=if(_time&amp;gt;one_mon_ago,1,0)
| stats count(eval(if(last_week_flag=1,_raw,""))) AS week_count avg(eval(if(last_mon_flag=1,_raw,""))) AS mon_avg_count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 May 2020 14:40:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502364#M139843</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2020-05-18T14:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to display count from last week and avg from last month on one timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502365#M139844</link>
      <description>&lt;P&gt;Thanks, but it doesn't work correctly. Displays only week_count result,  but mon_avg_count is empty. If change function from avg to count for (eval(if(last_mon_flag=1,_raw,""))) I receive the same result as for count(eval(if(last_week_flag=1,_raw,""))). &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:28:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502365#M139844</guid>
      <dc:creator>slipinski</dc:creator>
      <dc:date>2020-09-30T05:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to display count from last week and avg from last month on one timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502366#M139845</link>
      <description>&lt;P&gt;Opps, we're aggregating on a text value of _raw. Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="abc" sourcetype=alarms_log earliest=-30d@d latest=@d
 | bucket _time span=1day
 | eval one_week_ago=now()-604800
 | eval one_mon_ago=now()-2592000
 | eval last_week_flag=if(_time&amp;gt;one_week_ago,1,0)
 | stats count(eval(if(last_week_flag=1,_raw,""))) AS week_count by _time 
 | eval last_mon_flag=if(_time&amp;gt;one_mon_ago,1,0)
 | eventstats avg(eval(if(last_mon_flag=1,week_count,""))) AS mon_avg_count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 May 2020 15:51:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502366#M139845</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2020-05-19T15:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to display count from last week and avg from last month on one timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502367#M139846</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| tstats count where index=_internal earliest=-30d@d latest=@d by _time span=1d
| timewrap 1w
| untable _time days count
| eventstats avg(count) as monthly_avg  avg(eval(if(days="latest_week",count,NULL))) as weekly_avg by _time
| dedup monthly_avg weekly_avg
| table _time monthly_avg weekly_avg
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It's easy to use &lt;CODE&gt;timwrap&lt;/CODE&gt; and &lt;CODE&gt;untable&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 May 2020 20:08:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502367#M139846</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-05-19T20:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to display count from last week and avg from last month on one timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502368#M139847</link>
      <description>&lt;P&gt;Odd output &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Displays last_mon_flag instead mon_avg_count.&lt;/P&gt;

&lt;P&gt;_time   week_count  last_mon_flag&lt;BR /&gt;
1   2020-04-25  3   0&lt;BR /&gt;
2   2020-04-27  58  0&lt;BR /&gt;
3   2020-05-01  1   0&lt;BR /&gt;
4   2020-05-04  1   0&lt;BR /&gt;
5   2020-05-06  1   0&lt;BR /&gt;
6   2020-05-08  68  0&lt;BR /&gt;
7   2020-05-13  1   0&lt;BR /&gt;
8   2020-05-15  11  0&lt;BR /&gt;
9   2020-05-16  3   0&lt;BR /&gt;
10  2020-05-19  1   0&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:30:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-count-from-last-week-and-avg-from-last-month-on/m-p/502368#M139847</guid>
      <dc:creator>slipinski</dc:creator>
      <dc:date>2020-09-30T05:30:57Z</dc:date>
    </item>
  </channel>
</rss>

