SSE/Alerting: Support prom instant vector responses (#44865)

* SSE/Alerting: (Draft) Support prom instant vector responses
fixes #35663
* reduce\classic expressions to handle mathexp.Number
* use Notice for warning

Co-authored-by: Yuriy Tseretyan <yuriy.tseretyan@grafana.com>
This commit is contained in:
Kyle Brandt
2022-05-23 10:08:14 -04:00
committed by GitHub
co-authored by Yuriy Tseretyan
parent 0215195e6d
commit 01ef899753
10 changed files with 245 additions and 19 deletions
+33 -1
View File
@@ -6,9 +6,10 @@ import (
"testing"
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana/pkg/expr/mathexp"
"github.com/stretchr/testify/require"
ptr "github.com/xorcare/pointer"
"github.com/grafana/grafana/pkg/expr/mathexp"
)
func TestUnmarshalConditionCMD(t *testing.T) {
@@ -346,6 +347,37 @@ func TestConditionsCmdExecute(t *testing.T) {
return v
},
},
{
name: "should accept numbers",
vars: mathexp.Vars{
"A": mathexp.Results{
Values: []mathexp.Value{
valBasedNumber(ptr.Float64(5)),
valBasedNumber(ptr.Float64(10)),
valBasedNumber(ptr.Float64(15)),
},
},
},
conditionsCmd: &ConditionsCmd{
Conditions: []condition{
{
QueryRefID: "A",
Reducer: classicReducer("avg"),
Operator: "and",
Evaluator: &thresholdEvaluator{"gt", 1},
},
},
},
resultNumber: func() mathexp.Number {
v := valBasedNumber(ptr.Float64(1))
v.SetMeta([]EvalMatch{
{Value: ptr.Float64(5)},
{Value: ptr.Float64(10)},
{Value: ptr.Float64(15)},
})
return v
},
},
}
for _, tt := range tests {