From 841fb74b39736e85987389389c10a550543cc0fb Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Mon, 7 Nov 2016 23:15:47 -0800 Subject: [PATCH] Reversed loop for last function --- pkg/services/alerting/conditions/reducer.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/services/alerting/conditions/reducer.go b/pkg/services/alerting/conditions/reducer.go index 5fbaeb18326..988a640591d 100644 --- a/pkg/services/alerting/conditions/reducer.go +++ b/pkg/services/alerting/conditions/reducer.go @@ -63,10 +63,12 @@ func (s *SimpleReducer) Reduce(series *tsdb.TimeSeries) null.Float { value = float64(len(series.Points)) allNull = false case "last": - for _, point := range series.Points { - if point[0].Valid { - value = point[0].Float64 + points := series.Points + for i := len(points) - 1; i >= 0; i-- { + if points[i][0].Valid { + value = points[i][0].Float64 allNull = false + break } } }