Alerting: Do not persist noop transition from Normal state. (#61201)
* add feature flag `alertingNoNormalState` * update instance database to support exclusion of state in list operation * do not save normal state and delete transitions to normal * update get methods to filter out normal state
This commit is contained in:
@@ -30,15 +30,9 @@ func (st DBstore) ListAlertInstances(ctx context.Context, cmd *models.ListAlertI
|
||||
if cmd.RuleUID != "" {
|
||||
addToQuery(` AND rule_uid = ?`, cmd.RuleUID)
|
||||
}
|
||||
|
||||
if cmd.State != "" {
|
||||
addToQuery(` AND current_state = ?`, cmd.State)
|
||||
if st.FeatureToggles.IsEnabled(featuremgmt.FlagAlertingNoNormalState) {
|
||||
s.WriteString(fmt.Sprintf(" AND NOT (current_state = '%s' AND current_reason = '')", models.InstanceStateNormal))
|
||||
}
|
||||
|
||||
if cmd.StateReason != "" {
|
||||
addToQuery(` AND current_reason = ?`, cmd.StateReason)
|
||||
}
|
||||
|
||||
if err := sess.SQL(s.String(), params...).Find(&alertInstances); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user