Tag Archives: metrics

Grafana Elasticsearch Moving Averages

If you’re working with Elasticsearch data in Grafana, you may want to add moving averages to your graphs to help visualize trends over time. However, the process for doing so is not always well-documented. Fortunately, it’s actually quite simple.

First, add a new metric to your graph. From there, select “MovingFunction” and choose the metric you want to average. Then, expand the options and set the window to the number of samples you want your moving function to be based on.

Next, you’ll need to provide a script for the moving function to use. Depending on your needs, you can choose from several different options, including:

  • MovingFunctions.max(values)
  • MovingFunctions.min(values)
  • MovingFunctions.sum(values)
  • MovingFunctions.unweightedAvg(values)
  • MovingFunctions.linearWeightedAvg(values)

Once you’ve selected the appropriate script, you should be able to see your moving average data displayed on your graph.

While adding moving averages to Elasticsearch data in Grafana can be a helpful way to visualize trends, it can also be frustrating if you’re not sure how to do it. By following these simple steps, you’ll be able to quickly and easily add moving averages to your graphs and gain deeper insights into your data.

References:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-movfn-aggregation.html#:~:text=The%20Moving%20Function%20aggregation%20allows,script%20in%20the%20values%20variable.

Advertisement