Alerting: Do not retry rule evaluations with "input data must be a wide series but got type long" style errors (#87343)

add typed error for series must be wide, do not retry
pull/87461/head
Alexander Weaver 1 year ago committed by GitHub
parent 5fb87de321
commit 6c47968f6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      pkg/expr/converter.go
  2. 2
      pkg/expr/errors.go
  3. 5
      pkg/services/ngalert/eval/eval.go
  4. 12
      pkg/services/ngalert/eval/eval_test.go

@ -79,7 +79,7 @@ func (c *ResultConverter) Convert(ctx context.Context,
}
if schema.Type != data.TimeSeriesTypeWide && !allowLongFrames {
return "", mathexp.Results{}, fmt.Errorf("input data must be a wide series but got type %s (input refid)", schema.Type)
return "", mathexp.Results{}, fmt.Errorf("%w but got type %s (input refid)", ErrSeriesMustBeWide, schema.Type)
}
filtered = append(filtered, frame)
totalLen += len(schema.ValueIndices)
@ -249,7 +249,7 @@ func extractNumberSet(frame *data.Frame) ([]mathexp.Number, error) {
func WideToMany(frame *data.Frame, fixSeries func(series mathexp.Series, valueField *data.Field)) ([]mathexp.Series, error) {
tsSchema := frame.TimeSeriesSchema()
if tsSchema.Type != data.TimeSeriesTypeWide {
return nil, fmt.Errorf("input data must be a wide series but got type %s", tsSchema.Type)
return nil, fmt.Errorf("%w but got type %s", ErrSeriesMustBeWide, tsSchema.Type)
}
if len(tsSchema.ValueIndices) == 1 {

@ -7,6 +7,8 @@ import (
"github.com/grafana/grafana/pkg/util/errutil"
)
var ErrSeriesMustBeWide = errors.New("input data must be a wide series")
var ConversionError = errutil.BadRequest("sse.readDataError").MustTemplate(
"[{{ .Public.refId }}] got error: {{ .Error }}",
errutil.WithPublic(

@ -166,7 +166,7 @@ func (evalResults Results) HasErrors() bool {
// HasNonRetryableErrors returns true if we have at least 1 result with:
// 1. A `State` of `Error`
// 2. The `Error` attribute is not nil
// 3. The `Error` type is of `&invalidEvalResultFormatError`
// 3. The `Error` type is of `&invalidEvalResultFormatError` or `ErrSeriesMustBeWide`
// Our thinking with this approach, is that we don't want to retry errors that have relation with invalid alert definition format.
func (evalResults Results) HasNonRetryableErrors() bool {
for _, r := range evalResults {
@ -175,6 +175,9 @@ func (evalResults Results) HasNonRetryableErrors() bool {
if errors.As(r.Error, &nonRetryableError) {
return true
}
if errors.Is(r.Error, expr.ErrSeriesMustBeWide) {
return true
}
}
}
return false

@ -957,7 +957,7 @@ func TestResults_HasNonRetryableErrors(t *testing.T) {
expected bool
}{
{
name: "with non-retryable errors",
name: "with invalid format error",
eval: Results{
{
State: Error,
@ -966,6 +966,16 @@ func TestResults_HasNonRetryableErrors(t *testing.T) {
},
expected: true,
},
{
name: "with expected wide series but got type long error",
eval: Results{
{
State: Error,
Error: fmt.Errorf("%w but got type long", expr.ErrSeriesMustBeWide),
},
},
expected: true,
},
{
name: "with retryable errors",
eval: Results{

Loading…
Cancel
Save