Negative time shift for moving average?

Hello together,

I'm having a little problem with one of the panels I have created.

On this panel I am showing a line with an daily availability percentage (green line). Additionally I have created an moving average (blue line) with a 30 day window size. Is it possible to time shift the moving average into the negative, e.g. -1d, in any way, because I want the moving average to have the drop on the same day the green line drops down.

Here with my current test data I have an availability drop on May 10th, but the moving average only reflects it the day later, May 11th.

Thank you already in advance!

Unfortunately it's not possible to shift a series negatively. It seems like the underlying issue is that the moving average in Kibana is trailing, which means the current value is not taken into account. However you should be able to fix this with a formula like this:

moving_average(count(), window=5)*(5/6) + count()/6

Basically take the moving average and then add another value to it. Does that work for your case?

1 Like

I've just applied it to my panel and it seems to be working :smiley: But it smoothened out the line and it seems to not be dropping as hard as it was previously.

moving_average(average(myvalue), window=30) * (30/31) + average(myvalue)/31

I hope that I have translated the values correctly for my panel ^^

If you had a window of 30 before, then this effectively extended the window to 31 -

moving_average(average(myvalue), window=29) * (29/30) + average(myvalue)/30

would be a moving average with a window of 30 values including the current value and the 29 preceding ones.

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