mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(alerting): add support for count reducer
This commit is contained in:
parent
26c6437846
commit
77f9c24050
@ -42,6 +42,8 @@ func (s *SimpleReducer) Reduce(series *tsdb.TimeSeries) float64 {
|
||||
case "mean":
|
||||
meanPosition := int64(len(series.Points) / 2)
|
||||
value = series.Points[meanPosition][0]
|
||||
case "count":
|
||||
value = float64(len(series.Points))
|
||||
}
|
||||
|
||||
return value
|
||||
|
@ -34,6 +34,10 @@ func TestSimpleReducer(t *testing.T) {
|
||||
So(result, ShouldEqual, float64(2))
|
||||
})
|
||||
|
||||
Convey("count", func() {
|
||||
result := testReducer("count", 1, 2, 3000)
|
||||
So(result, ShouldEqual, float64(3))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user