diff --git a/pkg/services/ngalert/models/instance.go b/pkg/services/ngalert/models/instance.go index d2537ba7f03..64b2db99430 100644 --- a/pkg/services/ngalert/models/instance.go +++ b/pkg/services/ngalert/models/instance.go @@ -55,6 +55,7 @@ func (i InstanceStateType) IsValid() bool { type ListAlertInstancesQuery struct { RuleUID string RuleOrgID int64 `json:"-"` + RuleGroup string } // ValidateAlertInstance validates that the alert instance contains an alert rule id, diff --git a/pkg/services/ngalert/store/instance_database.go b/pkg/services/ngalert/store/instance_database.go index 4ede66e2a4a..35a88c9599c 100644 --- a/pkg/services/ngalert/store/instance_database.go +++ b/pkg/services/ngalert/store/instance_database.go @@ -33,6 +33,9 @@ func (st DBstore) ListAlertInstances(ctx context.Context, cmd *models.ListAlertI if cmd.RuleUID != "" { addToQuery(` AND rule_uid = ?`, cmd.RuleUID) } + if cmd.RuleGroup != "" { + return errors.New("filtering by RuleGroup is not supported") + } if st.FeatureToggles.IsEnabled(ctx, featuremgmt.FlagAlertingNoNormalState) { s.WriteString(fmt.Sprintf(" AND NOT (current_state = '%s' AND current_reason = '')", models.InstanceStateNormal))