mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
Added last function for alerting conditions
This commit is contained in:
parent
5bbdd99d35
commit
74632b5e98
@ -62,6 +62,13 @@ func (s *SimpleReducer) Reduce(series *tsdb.TimeSeries) null.Float {
|
||||
case "count":
|
||||
value = float64(len(series.Points))
|
||||
allNull = false
|
||||
case "last":
|
||||
for _, point := range series.Points {
|
||||
if point[0].Valid {
|
||||
value = point[0].Float64
|
||||
allNull = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if allNull {
|
||||
|
@ -35,6 +35,12 @@ func TestSimpleReducer(t *testing.T) {
|
||||
result := testReducer("count", 1, 2, 3000)
|
||||
So(result, ShouldEqual, float64(3))
|
||||
})
|
||||
|
||||
Convey("last", func() {
|
||||
result := testReducer("last", 1, 2, 3000)
|
||||
So(result, ShouldEqual, float64(3000))
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ var reducerTypes = [
|
||||
{text: 'max()', value: 'max'},
|
||||
{text: 'sum()' , value: 'sum'},
|
||||
{text: 'count()', value: 'count'},
|
||||
{text: 'last()', value: 'last'},
|
||||
];
|
||||
|
||||
var noDataModes = [
|
||||
|
Loading…
Reference in New Issue
Block a user