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

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

I'm using influxdb as the backend.

Grafana does no calculations itself, it just queries a backend and draws nice charts. So aggregating abilities depends solely on your backend. While Graphite supports windowing functions such as moving average, InfluxDB currently doesn't support it.

There are quite a lot requests for moving average in influxdb on the web. You can leave your "+1" and track progress in this ticket https://github.com/influxdb/influxdb/issues/77

Possible (yet not so easy) workaround is to create a custom script (cron, daemon, whatever) that will pre-calcuate MA and save it in a separate influxdb series.

**Question regarding moving average - Graph Panel,** When using influxdb behind grafana, the moving_average function is Is there a workaround to get the moving average series to show Grafana does no calculations itself, it just queries a backend and draws nice charts. So aggregating abilities depends solely on your backend. While Graphite supports windowing functions such as moving average, InfluxDB currently doesn't support it. There are quite a lot requests for moving average in influxdb on the web.

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:

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')

**What's new in Grafana v2.6,** This means that the moving average function is not taking in my latest if its a Grafana problem, would appreciate if you could take a look at it! To do this I need to make use of the moving average function in influx: Now the trick is when I enable the top query A, the result of query B loses the smoothing of the moving average: I am not entirely sure what I am missing, let me know if you see something naive being done here.

I found myself here trying to do a moving average in Grafana with a PostgreSQL database, so I'll just add a way to do with a SQL query:

SELECT date as time, AVG(daily_average_column) OVER(ORDER BY date ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) AS value, '5 Day Moving Average' as metric FROM daily_average_table ORDER BY time ASC;

This uses a "window" function to average of the last 4 rows (plus the current row).

I'm sure there are ways to do this with MySQL as well.

**moving_average in grafana always missing on left and sometimes ,** A transformation such as for example the moving average can be used to smooth the data and make trends easily visible. Moving average means that that a movingAverage(60) calculates moving average over 60 points (if metric has 1 second resolution it matches 1 minute window) percentile Takes a series of values and a window size and consolidate all its points fallen in the given interval into one point by Nth percentile.

Method and capability for this is dependent on your datasource.

You specified InfluxDB, so your query will need to wrap an 'Aggregation function' [ such as mean($field) ] within the moving_average($aggregation_function, $num_of_points) 'Transformation Function'.

In the 'Metrics' tab, you will find both the 'Transformation' functions in the 'select' portion of the menu.

Craft your query with the 'Aggregation function' (mean, min, max, etc.) first -- this way you can make sure the data looks as you expect it.

After this, just click the '+' button next to the 'Aggregation function', and under the menu 'Transformations', select 'moving_average'.

The number in brackets will be the number of points you want the average taken over.

**Screenshot:**

**Question regarding Grafana's Moving Average calculation · Issue ,** Functions with the parameter *seriesLists can take an arbitrary number of series lists. To pass The first period EMA uses a simple moving average for its value. Example: Graphs the linear regression function by least squares method. For some reason Grafana only supports the latter for movingMedian and the former for movingAverage. It is possible to enter a time period for movingAverage by manually putting it in quotes (e.g. movingAverage('10m')) but the editor will remove the quotes at some point so it becomes movingAverage(10m), breaking the syntax.

Another option is to report the data as "timing" metrics and not counts. This is easy to do especially with Statsd in your stack. Plotting timing data (coming from statsd) as average of the reported data points is already built in.

**How to Tune Your Grafana Dashboards,** While Graphite supports windowing functions such as moving average, InfluxDB currently doesn't support it. There are quite a lot requests for moving average in Multi-timeseries operations in Grafana. Ask Question Asked 4 years, 11 months ago. Active 1 year, 5 months ago. Is there a way to have a moving average in Grafana? 8.

**Functions - Graphite Documentation,** To do this I need to make use of the moving average function in influx: Now the trick is when I enable the top query A, the result of query B loses Some metric aggregations are called Pipeline aggregations, for example, Moving Average and Derivative. Elasticsearch pipeline metrics require another metric to be based on. Use the eye icon next to the metric to hide metrics from appearing in the graph. This is useful for metrics you only have in the query for use in a pipeline metric. Templating

**Is there a way to have a moving average in Grafana?,** What would you recommend to apply a smoothing factor to make it more you the rolling average of the gage, matched to the step in Grafana. Applying a moving average with window size 10 to the output means that 10 of the mean values are taken and the mean of the means is than calculated. This is possible for the first time when 10 mean values are available, so after 6h x 10 = 60h = 2.5d. Grafana depicts the obtained value not at the center of the window but at its end.

**Grafana v3 with influxdb v12: Layering a moving_average() query ,** Grafana is the open source analytics & monitoring solution for every database The open observability platform Grafana is the open source analytics and monitoring solution for every database Get Grafana Learn more Used by thousands of companies to monitor everything from infrastructure, applications, and power plants to beehives.