# Simple moving average in Kibana over a date histogram help

**URL:** https://discuss.elastic.co/t/simple-moving-average-in-kibana-over-a-date-histogram-help/77249
**Category:** Kibana
**Created:** [March 3, 2017, 3:28am UTC](https://discuss.elastic.co/t/simple-moving-average-in-kibana-over-a-date-histogram-help/77249 "2017-03-03T03:28:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mmoxam](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@mmoxam](https://discuss.elastic.co/u/mmoxam)
#### Post date: [March 3, 2017, 3:28am UTC](https://discuss.elastic.co/t/simple-moving-average-in-kibana-over-a-date-histogram-help/77249/1 "2017-03-03T03:28:14Z")

</div>

Can someone explain or show me how to add a simple moving average over a line chart with a date histogram in Kibana?

I see the documentation on moving average but it's not clear how I would use it in Kibana.

---

<div class="post-metadata">

### Author: ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)
#### Post date: [March 3, 2017, 5:18pm UTC](https://discuss.elastic.co/t/simple-moving-average-in-kibana-over-a-date-histogram-help/77249/2 "2017-03-03T17:18:09Z")

</div>

If you're on a recent version of Kibana with Timelion built-in (or older version with Timelion plugin installed) you can do something like this;

The query I used was;  
`.es(index='metricbeat-*', metric='max:metricset.rtt') .es(index='metricbeat-*', metric='max:metricset.rtt').movingaverage(10)`

The first line generated by `.es(index='metricbeat-*', metric='max:metricset.rtt')` is just the `max:metricset.rtt` from the metricbeat-\* index pattern.

The second line in the chart generated by `.es(index='metricbeat-*', metric='max:metricset.rtt').movingaverage(10)` is the moving average over 10 samples.

 ![](https://us1.discourse-cdn.com/elastic/original/3X/1/b/1b33ba5007fef61a8326fe6ef40c3dba8e9453c6.png)

You can do this in the Timelion app where there's a handy function reference and tutorial. Or as a Timeseries visualization.

Let me know if this helps.

Regards,  
Lee

---

<div class="post-metadata">

### Author: ![mmoxam](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@mmoxam](https://discuss.elastic.co/u/mmoxam)
#### Post date: [March 3, 2017, 6:52pm UTC](https://discuss.elastic.co/t/simple-moving-average-in-kibana-over-a-date-histogram-help/77249/3 "2017-03-03T18:52:55Z")

</div>

Thank you this works for me.

Much appreciated.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [March 31, 2017, 6:52pm UTC](https://discuss.elastic.co/t/simple-moving-average-in-kibana-over-a-date-histogram-help/77249/4 "2017-03-31T18:52:57Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
