Monthly Archives: May 2022

Grafana Elasticsearch Moving Averages

Adding moving averages to a graph of Elasticsearch data in grafana is pretty easy, but not well documented

  1. Add a new metric
  2. Choose MovingFunction and pick the metric you want an average on
  3. Expand the options, set Window to the number of samples you want to have your moving function on
  4. Script should be one of the following:
    1. MovingFunctions.max(values)
    2. MovingFunctions.min(values)
    3. MovingFunctions.sum(values)
    4. MovingFunctions.unweightedAvg(values)
    5. MovingFunctions.linearWeightedAvg(values)

Reference: 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.