Alerting: Add RuleGroup field to ListAlertInstancesQuery struct (#94615)

Alerting: add RuleGroup field to ListAlertInstancesQuery struct
This commit is contained in:
Alexander Akhmetov 2024-10-18 09:44:16 +02:00 committed by GitHub
parent 22d5efba25
commit 0b804e720f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View File

@ -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,

View File

@ -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))