# Alert based on percentage change of aggregated, weekly averages

**URL:** <https://community.grafana.com/t/alert-based-on-percentage-change-of-aggregated-weekly-averages/37721>\
**Category:** Alerting\
**Tags:** alerting\
**Created:** [October 9, 2020, 7:54am UTC](https://community.grafana.com/t/alert-based-on-percentage-change-of-aggregated-weekly-averages/37721 "2020-10-09T07:54:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wayneliu1](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/wayneliu1/32/13150_2.png) [@wayneliu1](https://community.grafana.com/u/wayneliu1)\
**Post date:** [October 9, 2020, 7:54am UTC](https://community.grafana.com/t/alert-based-on-percentage-change-of-aggregated-weekly-averages/37721/1 "2020-10-09T07:54:09Z")

</div>

Hi Grafana fam, Quick question regarding alert configuration.

We have configured alerts to monitor specific metric and if they are over the threshold. (In our case, response Time of APIs.) However, is it possible to monitor the % change in past 7 days? Our goal is to set alerts to monitor the change % of average response time in the past 7 days. So basically an alert like this,

WHEN percentage\_diff between A and B, when B is query A but with timeShift 7 days.

Due the the fact that alert is only supported in Graph panel in time series, not sure if it’s doable as query A always returns one single metric at a given time, instead of a daily/weekly/monthly average in an aggregated fashion.

Thanks all!

---

<div class="post-metadata">

**Author:** ![melrose](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/melrose/32/14147_2.png) [@melrose](https://community.grafana.com/u/melrose)\
**Post date:** [October 9, 2020, 5:34pm UTC](https://community.grafana.com/t/alert-based-on-percentage-change-of-aggregated-weekly-averages/37721/2 "2020-10-09T17:34:52Z")

</div>

> [@wayneliu1](#):
>
> rt is only supported in Graph panel in time series, not sure if it’s doable as query A always returns one single metric at a given time, instead of a daily/weekly/monthly average in an aggregated fashion.

ok, what is the question?

---

<div class="post-metadata">

**Author:** ![sskrlj](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/sskrlj/32/13149_2.png) [@sskrlj](https://community.grafana.com/u/sskrlj)\
**Post date:** [October 9, 2020, 7:36pm UTC](https://community.grafana.com/t/alert-based-on-percentage-change-of-aggregated-weekly-averages/37721/3 "2020-10-09T19:36:20Z")

</div>

Depending on your metrics provider. If it’s Prometheus, you can do something like `my_metric / my_metric offset 1w`. It’s current value of metric divided by the value of the same metric 1w ago. You should be able to turn this into alerting easily.

---

<div class="post-metadata">

**Author:** ![wayneliu1](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/wayneliu1/32/13150_2.png) [@wayneliu1](https://community.grafana.com/u/wayneliu1)\
**Post date:** [October 10, 2020, 11:49am UTC](https://community.grafana.com/t/alert-based-on-percentage-change-of-aggregated-weekly-averages/37721/5 "2020-10-10T11:49:57Z")

</div>

I want to set alert to compare with average from now to 7 days ago (A), and 7 days ago to 14 days ago (B). Then notify me if the change % between A and B is greater than 10%.

My b could’ve been more clear on my goal. Thanks for the help!

---

<div class="post-metadata">

**Author:** ![sskrlj](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/sskrlj/32/13149_2.png) [@sskrlj](https://community.grafana.com/u/sskrlj)\
**Post date:** [October 11, 2020, 11:24am UTC](https://community.grafana.com/t/alert-based-on-percentage-change-of-aggregated-weekly-averages/37721/6 "2020-10-11T11:24:15Z")

</div>

In that case,

> `my_metric / avg_over_time(my_metric[1w])`

and

> `my_metric / avg_over_time(my_metric[1w] offset 1w)`

should do the trick.
