<?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 set up alerts when current week data is more than avg of last 4 weeks data ? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-up-alerts-when-current-week-data-is-more-than-avg-of/m-p/549249#M37863</link>
    <description>&lt;P&gt;You need to snap latest to the start of the day so you don't get today's events included and the comparisons should have been &amp;gt;= not just &amp;gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ndex=indexname ns=namespace earliest=-35d@d latest=@d
| search API= API1 AND Customer= Customer1
| bin _time span=1w
| stats count by _time Customer API
| eval previous = if(_time &amp;gt;= relative_time(now(), "-1w@w"), null, count)
| eventstats avg(previous) as average by Customer API
| where _time &amp;gt;= relative_time(now(), "-1w@w")
| fields - previous
| where count &amp;gt; average&lt;/LI-CODE&gt;&lt;P&gt;The count is for 7 days starting from the date in the _time column&lt;/P&gt;</description>
    <pubDate>Sun, 25 Apr 2021 05:46:48 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2021-04-25T05:46:48Z</dc:date>
    <item>
      <title>How to set up alerts when current week data is more than avg of last 4 weeks data ?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-up-alerts-when-current-week-data-is-more-than-avg-of/m-p/549201#M37856</link>
      <description>&lt;P&gt;Hi All.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to check if there is any means by which I can set up alerts if&amp;nbsp; the current week's data is more than the avg of last 4 week's data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have around 25 customers hitting 3 APIs. I want to compare if first customer has hit the first API more in the current week when compared to the avg number of hits in the previous 4 week's, and then send an alert if it exceeds the avg.&amp;nbsp;&lt;BR /&gt;&amp;nbsp; Similarly for all the customers and the 3 APIs.&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the above operation should happen with a single Splunk query. I don't want to write 25*3=75 queries for the alerts.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I have written a query for 1 customer and 1 API&lt;/P&gt;&lt;P&gt;index=nameofindex ns=namespace process="end" method!=GET earliest=-30d@d&amp;nbsp; &amp;nbsp;customer1&lt;BR /&gt;| search API="API1"&lt;BR /&gt;| timechart span=1w count&lt;BR /&gt;| timewrap w series=short&lt;BR /&gt;| eval mean=(s1+s2+s3+s4)/4&lt;BR /&gt;| where s0 &amp;gt; mean&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Can anyone please help here ? Any help is greatly appreciated. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 23:15:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-up-alerts-when-current-week-data-is-more-than-avg-of/m-p/549201#M37856</guid>
      <dc:creator>rahul_n</dc:creator>
      <dc:date>2021-04-23T23:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to set up alerts when current week data is more than avg of last 4 weeks data ?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-up-alerts-when-current-week-data-is-more-than-avg-of/m-p/549214#M37858</link>
      <description>&lt;LI-CODE lang="markup"&gt;| gentimes start=-35 increment=1d
| rename starttime as _time 
| fields _time
| eval customer=split("customer1,customer2,customer3",",")
| mvexpand customer
| eval api=split("API1,API2,API3",",")
| mvexpand api
| eval count=random() % 20


| bin _time span=1w
| stats sum(count) as count by _time customer api
| eval previous=if(_time &amp;gt; relative_time(now(),"-1w@w"),null,count)
| eventstats avg(previous) as average by customer api
| where _time &amp;gt; relative_time(now(),"-1w@w")
| fields - previous&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 24 Apr 2021 15:35:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-up-alerts-when-current-week-data-is-more-than-avg-of/m-p/549214#M37858</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-04-24T15:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to set up alerts when current week data is more than avg of last 4 weeks data ?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-up-alerts-when-current-week-data-is-more-than-avg-of/m-p/549228#M37860</link>
      <description>&lt;P&gt;Hi&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;Thank you for the quick response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have few questions on the query.&lt;/P&gt;&lt;P&gt;1. I need to pass an index, a namespace and few other parameters (like, index=indexname ns=namespace process="end" method!=GET pod_name=podname&amp;nbsp; region=regionname) before passing the actual query.&amp;nbsp;&lt;/P&gt;&lt;P&gt;By using the gentimes command, its not allowing me to pass the basic query as mentioned above.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Also, if I use the split() command with customer names or API names in it, it is&amp;nbsp; not working , and the similar goes with split() command with api names.&amp;nbsp; ( For reference: We have the fields Customer and API in the logs )&lt;/P&gt;&lt;P&gt;4. The count must be the number of times a customer has accessed an API&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;For reference, I use&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;"&amp;lt;basic splunk query&amp;gt; | timechart count by API"&amp;nbsp; &amp;nbsp;to get the the timechart showing the count. (We have the field API in the logs, which makes it easy)&lt;/P&gt;&lt;P&gt;Will that be possible for you to modify the query based on the above conditions ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sorry for asking too much, but I tried multiple ways and left with no results&lt;/P&gt;&lt;P&gt;Thank you very much in advance&lt;/P&gt;</description>
      <pubDate>Sat, 24 Apr 2021 23:21:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-up-alerts-when-current-week-data-is-more-than-avg-of/m-p/549228#M37860</guid>
      <dc:creator>rahul_n</dc:creator>
      <dc:date>2021-04-24T23:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to set up alerts when current week data is more than avg of last 4 weeks data ?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-up-alerts-when-current-week-data-is-more-than-avg-of/m-p/549230#M37861</link>
      <description>&lt;P&gt;The example was a run-anywhere example to show the sort of thing to try. In your case, you just need the bit after the blank lines.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;basic splunk query&amp;gt;
| bin _time span=1w
| stats count by _time Customer API
| eval previous=if(_time &amp;gt; relative_time(now(),"-1w@w"),null,count)
| eventstats avg(previous) as average by Customer API
| where _time &amp;gt; relative_time(now(),"-1w@w")
| fields - previous&lt;/LI-CODE&gt;&lt;P&gt;You should probably use an earliest time of &lt;A href="mailto:-35d@d" target="_blank"&gt;-35d@d&lt;/A&gt;&amp;nbsp;as well to get complete weeks.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Apr 2021 23:53:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-up-alerts-when-current-week-data-is-more-than-avg-of/m-p/549230#M37861</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-04-24T23:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to set up alerts when current week data is more than avg of last 4 weeks data ?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-up-alerts-when-current-week-data-is-more-than-avg-of/m-p/549240#M37862</link>
      <description>&lt;P&gt;Hi&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;By using the given query, which is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;index=indexname ns=namespace earliest=-35d@d&lt;/P&gt;&lt;P&gt;| search API= API1 AND Customer= Customer1&lt;/P&gt;&lt;P&gt;| bin _time span=1w&lt;/P&gt;&lt;P&gt;| stats count by _time&amp;nbsp;Customer API&lt;/P&gt;&lt;P&gt;| eval previous = if(_time &amp;gt; relative_time(now(), "-1w@w"), null, count)&lt;/P&gt;&lt;P&gt;| eventstats avg(previous) as average by&amp;nbsp;Customer API&lt;/P&gt;&lt;P&gt;| where _time &amp;gt; relative_time(now(), "-1w@w")&lt;/P&gt;&lt;P&gt;| fields - previous&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The table which I got for one customer and one API is&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%"&gt;_time&lt;/TD&gt;&lt;TD width="25%"&gt;Customer&lt;/TD&gt;&lt;TD width="25%"&gt;API&lt;/TD&gt;&lt;TD width="12.5%"&gt;count&lt;/TD&gt;&lt;TD width="12.5%"&gt;average&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;2021-04-17&lt;/TD&gt;&lt;TD width="25%"&gt;Customer1&lt;/TD&gt;&lt;TD width="25%"&gt;API1&lt;/TD&gt;&lt;TD width="12.5%"&gt;83936&lt;/TD&gt;&lt;TD width="12.5%"&gt;6348.25&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;2021-04-24&lt;/TD&gt;&lt;TD width="25%"&gt;Customer1&lt;/TD&gt;&lt;TD width="25%"&gt;API1&lt;/TD&gt;&lt;TD width="12.5%"&gt;866&lt;/TD&gt;&lt;TD width="12.5%"&gt;6374&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here, does the "count" refer to the count of requests for the week starting with the date in first column ? or the end date ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does the _time refer to the start day of the week or the end day of the week ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can we change the query so that we get the results which have the current week's count is greater than the average of last 4 week's count ? (So that I can create an alert which sends the list of customers sending more requests in current week )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the help and any help in advance&lt;/P&gt;</description>
      <pubDate>Sun, 25 Apr 2021 02:42:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-up-alerts-when-current-week-data-is-more-than-avg-of/m-p/549240#M37862</guid>
      <dc:creator>rahul_n</dc:creator>
      <dc:date>2021-04-25T02:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to set up alerts when current week data is more than avg of last 4 weeks data ?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-up-alerts-when-current-week-data-is-more-than-avg-of/m-p/549249#M37863</link>
      <description>&lt;P&gt;You need to snap latest to the start of the day so you don't get today's events included and the comparisons should have been &amp;gt;= not just &amp;gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ndex=indexname ns=namespace earliest=-35d@d latest=@d
| search API= API1 AND Customer= Customer1
| bin _time span=1w
| stats count by _time Customer API
| eval previous = if(_time &amp;gt;= relative_time(now(), "-1w@w"), null, count)
| eventstats avg(previous) as average by Customer API
| where _time &amp;gt;= relative_time(now(), "-1w@w")
| fields - previous
| where count &amp;gt; average&lt;/LI-CODE&gt;&lt;P&gt;The count is for 7 days starting from the date in the _time column&lt;/P&gt;</description>
      <pubDate>Sun, 25 Apr 2021 05:46:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-up-alerts-when-current-week-data-is-more-than-avg-of/m-p/549249#M37863</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-04-25T05:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to set up alerts when current week data is more than avg of last 4 weeks data ?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-up-alerts-when-current-week-data-is-more-than-avg-of/m-p/549869#M37932</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;, Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 15:19:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-up-alerts-when-current-week-data-is-more-than-avg-of/m-p/549869#M37932</guid>
      <dc:creator>rahul_n</dc:creator>
      <dc:date>2021-04-29T15:19:23Z</dc:date>
    </item>
  </channel>
</rss>

