mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -209,19 +209,22 @@ func (c *cache) get(orgID int64, alertRuleUID, stateId string) *State {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *cache) getAll(orgID int64) []*State {
|
||||
func (c *cache) getAll(orgID int64, skipNormalState bool) []*State {
|
||||
var states []*State
|
||||
c.mtxStates.RLock()
|
||||
defer c.mtxStates.RUnlock()
|
||||
for _, v1 := range c.states[orgID] {
|
||||
for _, v2 := range v1.states {
|
||||
if skipNormalState && IsNormalStateWithNoReason(v2) {
|
||||
continue
|
||||
}
|
||||
states = append(states, v2)
|
||||
}
|
||||
}
|
||||
return states
|
||||
}
|
||||
|
||||
func (c *cache) getStatesForRuleUID(orgID int64, alertRuleUID string) []*State {
|
||||
func (c *cache) getStatesForRuleUID(orgID int64, alertRuleUID string, skipNormalState bool) []*State {
|
||||
c.mtxStates.RLock()
|
||||
defer c.mtxStates.RUnlock()
|
||||
orgRules, ok := c.states[orgID]
|
||||
@@ -234,6 +237,9 @@ func (c *cache) getStatesForRuleUID(orgID int64, alertRuleUID string) []*State {
|
||||
}
|
||||
result := make([]*State, 0, len(rs.states))
|
||||
for _, state := range rs.states {
|
||||
if skipNormalState && IsNormalStateWithNoReason(state) {
|
||||
continue
|
||||
}
|
||||
result = append(result, state)
|
||||
}
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user