mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 20:59:35 +08:00
SSE: Fix NoData when some series were no data but others not (#45867)
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
This commit is contained in:
@ -129,7 +129,7 @@ func (ccc *ConditionsCmd) Execute(ctx context.Context, vars mathexp.Vars) (mathe
|
|||||||
}
|
}
|
||||||
|
|
||||||
thisCondFiring := firingCount > 0
|
thisCondFiring := firingCount > 0
|
||||||
thisCondNoData := nilReducedCount > 0
|
thisCondNoData := len(querySeriesSet.Values) == nilReducedCount
|
||||||
|
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
firing = thisCondFiring
|
firing = thisCondFiring
|
||||||
@ -144,7 +144,7 @@ func (ccc *ConditionsCmd) Execute(ctx context.Context, vars mathexp.Vars) (mathe
|
|||||||
noDataFound = noDataFound && thisCondNoData
|
noDataFound = noDataFound && thisCondNoData
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(querySeriesSet.Values) == nilReducedCount {
|
if thisCondNoData {
|
||||||
matches = append(matches, EvalMatch{
|
matches = append(matches, EvalMatch{
|
||||||
Metric: "NoData",
|
Metric: "NoData",
|
||||||
})
|
})
|
||||||
|
@ -169,6 +169,31 @@ func TestConditionsCmdExecute(t *testing.T) {
|
|||||||
return v
|
return v
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "single query and single condition - empty series and not empty series",
|
||||||
|
vars: mathexp.Vars{
|
||||||
|
"A": mathexp.Results{
|
||||||
|
Values: []mathexp.Value{
|
||||||
|
valBasedSeries(),
|
||||||
|
valBasedSeries(ptr.Float64(3)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
conditionsCmd: &ConditionsCmd{
|
||||||
|
Conditions: []condition{
|
||||||
|
{
|
||||||
|
QueryRefID: "A",
|
||||||
|
Reducer: classicReducer("avg"),
|
||||||
|
Operator: "and",
|
||||||
|
Evaluator: &thresholdEvaluator{Type: "gt", Threshold: .5},
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
resultNumber: func() mathexp.Number {
|
||||||
|
v := valBasedNumber(ptr.Float64(1))
|
||||||
|
v.SetMeta([]EvalMatch{{Value: ptr.Float64(3)}})
|
||||||
|
return v
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "single query and two conditions",
|
name: "single query and two conditions",
|
||||||
vars: mathexp.Vars{
|
vars: mathexp.Vars{
|
||||||
|
@ -102,6 +102,12 @@ func TestReducer(t *testing.T) {
|
|||||||
inputSeries: valBasedSeries(nil, nil, ptr.Float64(3), ptr.Float64(4)),
|
inputSeries: valBasedSeries(nil, nil, ptr.Float64(3), ptr.Float64(4)),
|
||||||
expectedNumber: valBasedNumber(ptr.Float64(2)),
|
expectedNumber: valBasedNumber(ptr.Float64(2)),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "count_non_null with mixed null/real values",
|
||||||
|
reducer: classicReducer("count_non_null"),
|
||||||
|
inputSeries: valBasedSeries(nil, nil, ptr.Float64(3), ptr.Float64(4)),
|
||||||
|
expectedNumber: valBasedNumber(ptr.Float64(2)),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "count_non_null with no values",
|
name: "count_non_null with no values",
|
||||||
reducer: classicReducer("count_non_null"),
|
reducer: classicReducer("count_non_null"),
|
||||||
|
Reference in New Issue
Block a user