Dynamically change Moving Average (Timelion)


Is there a way to dynamically change the moving average function in timelion. For example could I somehow write a conditional statement that references the selection of the time picker? So for example if the time picker is set to show the past 7 days then I want to have a moving avg of (2), whereas I would like to have a moving avg of (7) when the time picker includes a greater timeinterval than 7 days. Or generally is there a better workaround than this?

Thank you for your help!


Hi @Max_Handle!
The time picker only filters documents that are read from elasticsearch. What that means is that when the timepicker is set for the last 7 days, es queries only return the last 7 days of docs.

As for workarounds: you might be able to set the moving average value using a conditional on the date range for the documents you do return (filtered based off of the timepicker). There's also a blog post that looks like it could help: https://www.elastic.co/blog/timeseries-if-then-else-with-timelion. Good luck!

1 Like

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