Is there a way to have a moving average in Grafana?

brunoqc picture brunoqc · Dec 15, 2014 · Viewed 45.2k times · Source

I didn't find a 'moving average' feature and I'm wondering if there's a workaround.

I'm using influxdb as the backend.

Answer

user559633 picture user559633 · Dec 15, 2014

Grafana supports adding a movingAverage(). I also had a hard time finding it in the docs, but you can (somewhat hilariously) see its usage on the feature intro page:

screenshot showing movingAverage() call

As is normal, click on the graph title, edit, add the metric movingAverage() as per described in the graphite documentation:

movingAverage(seriesList, windowSize)

Graphs the moving average of a metric (or metrics) over a fixed number of past points, or a time interval.

Takes one metric or a wildcard seriesList followed by a number N of datapoints or a quoted string with a length of time like ‘1hour’ or ‘5min’ (See from / until in the render_api_ for examples of time formats). Graphs the average of the preceding datapoints for each point on the graph. All previous datapoints are set to None at the beginning of the graph.

Example:

&target=movingAverage(Server.instance01.threads.busy,10)
&target=movingAverage(Server.instance*.threads.idle,'5min')