GoshPosh / grafana-meta-queries

Grafana plugin for calculating time period metrics like week over week, month over month and year over year etc.
Apache License 2.0
283 stars 71 forks source link

Moving Average: support of movingAverageUnits instead of Period to give flexibility to adapt to any needed time window #107

Open arigit opened 4 years ago

arigit commented 4 years ago

With reference to the discussion in #104

My use case: I have an IP bandwidth graph that is sampled once every 10 seconds. I am trying to use the Moving Average meta-query to add a moving average curve, and I need the time-window of the moving average to be 5 minutes, ie 30 samples.

I just discovered this plugin and it's functionality seems to fit my use case like a glove however, when I configured it assuming that the "Period" parameter was the "samples in the MA time window", I noticed that the moving avearge was flat (zero) with Period = 30, and then changing the Period to 4 I got the graph below, which is obviously not what I expected.

image

image

image

The thanks to @Gauravshah I realized that the "Period" parameter is in "Days" hence the issue.

So this is a request to change (or add a capability) to the Moving Average graphs to allow the "Time Window" to be specified in "units" (sample periods), e.g. if my graph has a datapoint every 10 seconds, then setting the Time Window to: 30 samples, should apply a 5-minute sliding window for the moving average.

Gauravshah commented 4 years ago

posting from #104

we added support for timeshiftUnits I think we need to add same for Moving Average that should fix your issue.
https://github.com/GoshPosh/grafana-meta-queries/pull/62/files