From e5ebdb26912a039afeb2da0779af73cd27c1d9c6 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Wed, 26 Jul 2017 13:37:07 +0300 Subject: [PATCH] docs: movingAverage and exponentialMovingAverage reference --- CHANGELOG.md | 1 + docs/sources/reference/functions.md | 36 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce9c0bc..d89fa03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `consolidateBy` function, which allows to specify aggregation function for time series data. - Direct DB Connection, which allows to use existing SQL data source for querying history data directly from Zabbix database. - **Docs**: Direct DB Connection reference and configuration. +- `movingAverage` and `exponentialMovingAverage` functions. ### Changed - IT Services query editor. Now user able to select multiple services by using regex, [#415](https://github.com/alexanderzobnin/grafana-zabbix/issues/415) diff --git a/docs/sources/reference/functions.md b/docs/sources/reference/functions.md index 69aba1b..4a6e514 100644 --- a/docs/sources/reference/functions.md +++ b/docs/sources/reference/functions.md @@ -44,6 +44,42 @@ rate() Calculates the per-second rate of increase of the time series. Resistant to counter reset. Suitable for converting of growing counters into the per-sercond rate. +### movingAverage +``` +movingAverage(windowSize) +``` +Graphs the moving average of a metric over a fixed number of past points, specified by `windowSize` param. + +Examples: +``` +movingAverage(60) +calculates moving average over 60 points (if metric has 1 second resolution it matches 1 minute window) +``` + +### exponentialMovingAverage +``` +exponentialMovingAverage(windowSize) +``` +Takes a series of values and a window size and produces an exponential moving average utilizing the following formula: +`ema(current) = constant * (Current Value) + (1 - constant) * ema(previous)` + +The Constant is calculated as: +`constant = 2 / (windowSize + 1)` + +If windowSize < 1 (0.1, for instance), Constant wouldn't be calculated and will be taken directly from windowSize +(Constant = windowSize). + +It's a bit tricky to graph EMA from the first point of series (not from Nth = windowSize). In order to do it, +plugin should fetch previous N points first and calculate simple moving average for it. To avoid it, plugin uses this +hack: assume, previous N points have the same average values as first N (windowSize). So you should keep this fact +in mind and don't rely on first N points interval. + +Examples: +``` +movingAverage(60) +calculates moving average over 60 points (if metric has 1 second resolution it matches 1 minute window) +``` + Aggregate ---------