Alerting: Maintain endsAt for missing alert instances that are not stale yet (#107011)

This commit is contained in:
Alexander Akhmetov
2025-06-20 14:31:21 +02:00
committed by GitHub
parent 18cb131a2a
commit ac832c157e
2 changed files with 11 additions and 7 deletions
+4
View File
@@ -566,6 +566,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{
@@ -675,7 +675,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),
FiredAt: &t1,
LastEvaluationTime: t1,
LastSentAt: &t1,
@@ -1055,7 +1055,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),
FiredAt: &t1,
LastEvaluationTime: t1,
LastSentAt: &t1,
@@ -1133,7 +1133,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),
FiredAt: &t1,
LastEvaluationTime: t1,
LastSentAt: &t1,
@@ -1679,7 +1679,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),
FiredAt: &t1,
LastEvaluationTime: t1,
LastSentAt: &t1,
@@ -2379,7 +2379,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),
FiredAt: &t1,
LastEvaluationTime: t1,
LastSentAt: &t1,
@@ -2962,7 +2962,7 @@ func TestProcessEvalResults_StateTransitions(t *testing.T) {
StateReason: ngmodels.StateReasonNoData,
LatestResult: newEvaluation(t1, eval.NoData),
StartsAt: t1,
EndsAt: t1.Add(ResendDelay * 4),
EndsAt: t2.Add(ResendDelay * 4),
FiredAt: &t1,
LastEvaluationTime: t1,
LastSentAt: &t1,
@@ -3226,7 +3226,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),
FiredAt: &t1,
LastEvaluationTime: t1,
LastSentAt: &t1,