Percentage of average

Hello All,

I’m using Grafana with Influx DB and need some advise on how to effectively achieve the percentage values of average. So we some devices sending traffic volume and I would like to know if the volume goes down by 90%.

e.g. Device A is sending 1000 in the past one hour (avg) and this value goes to 100 in the last 30 minutes (avg) which is a reduction of 90%.

Device B is sending 2000 in the past one hour (avg) and this value goes to 1000 in the last 30 minutes (avg) which is reduction of 50%.

The challenge of taking the “number values” of traffic is , we have different devices with different logging values so I can’t effectively create a alert threshold using number.

In my query , I used the concept

Last value - Moving average of 2 values/ Moving average of 2 values 100 = Percentage Variation*

SELECT (((last(“value”) - moving_average(sum(“value”),2)) / moving_average(sum(“value”),2)) * 100 ) FROM “x”.“x” WHERE (“process” = ‘x’ AND “value” > 10000) AND $timeFilter GROUP BY time(15m), “xx”“xx”

I have to taken consideration of spikes happening and the percentage variation changing due to that as well. Any advise on how to calculate/compare the current average of 30 minutes with the avg of previous of one hour or even the same average during this time last week.

Data Structure is:

10:00 - 1000
10:15 - 1000
10:30 - 500
10:45 - 1000

Compare this average with

11:00 - 200
11:15 - 0