[release-12.0.3] Alerting: Maintain endsAt for missing alert instances that are not stale yet (#107078)

Alerting: Maintain endsAt for missing alert instances that are not stale yet (#107011)
This commit is contained in:
Alexander Akhmetov
2025-06-24 11:56:48 +02:00
committed by GitHub
parent 3de18b7281
commit 037fe5dfe9
2 changed files with 10 additions and 6 deletions
+4
View File
@@ -557,6 +557,10 @@ func (st *Manager) processMissingSeriesStates(logger log.Logger, evaluatedAt tim
}
staleStatesCount++
} else if s.State == eval.Alerting {
// We need to update EndsAt for the state so that it will not be resolved by the
// Alertmanager automatically.
s.Maintain(alertRule.IntervalSeconds, evaluatedAt)
}
record := StateTransition{
@@ -671,7 +671,7 @@ func TestProcessEvalResults_StateTransitions(t *testing.T) {
State: eval.Alerting,
LatestResult: newEvaluation(t1, eval.Alerting),
StartsAt: t1,
EndsAt: t1.Add(ResendDelay * 4),
EndsAt: t2.Add(ResendDelay * 4),
LastEvaluationTime: t1,
LastSentAt: &t1,
},
@@ -1037,7 +1037,7 @@ func TestProcessEvalResults_StateTransitions(t *testing.T) {
State: eval.Alerting,
LatestResult: newEvaluation(t1, eval.Alerting),
StartsAt: t1,
EndsAt: t1.Add(ResendDelay * 4),
EndsAt: t2.Add(ResendDelay * 4),
LastEvaluationTime: t1,
LastSentAt: &t1,
},
@@ -1113,7 +1113,7 @@ func TestProcessEvalResults_StateTransitions(t *testing.T) {
State: eval.Alerting,
LatestResult: newEvaluation(t1, eval.Alerting),
StartsAt: t1,
EndsAt: t1.Add(ResendDelay * 4),
EndsAt: t3.Add(ResendDelay * 4),
LastEvaluationTime: t1,
LastSentAt: &t1,
},
@@ -1647,7 +1647,7 @@ func TestProcessEvalResults_StateTransitions(t *testing.T) {
State: eval.Alerting,
LatestResult: newEvaluation(t1, eval.Alerting),
StartsAt: t1,
EndsAt: t1.Add(ResendDelay * 4),
EndsAt: t2.Add(ResendDelay * 4),
LastEvaluationTime: t1,
LastSentAt: &t1,
EvaluationDuration: time.Millisecond * 10,
@@ -2327,7 +2327,7 @@ func TestProcessEvalResults_StateTransitions(t *testing.T) {
State: eval.Alerting,
LatestResult: newEvaluation(t1, eval.Alerting),
StartsAt: t1,
EndsAt: t1.Add(ResendDelay * 4),
EndsAt: t2.Add(ResendDelay * 4),
LastEvaluationTime: t1,
LastSentAt: &t1,
EvaluationDuration: time.Millisecond * 10,
@@ -3063,7 +3063,7 @@ func TestProcessEvalResults_StateTransitions(t *testing.T) {
State: eval.Alerting,
LatestResult: newEvaluation(t1, eval.Alerting),
StartsAt: t1,
EndsAt: t1.Add(ResendDelay * 4),
EndsAt: t2.Add(ResendDelay * 4),
LastEvaluationTime: t1,
LastSentAt: &t1,
EvaluationDuration: time.Millisecond * 10,