Skip to content

Commit

Permalink
ingest: respect maxActiveAlerts even for addedJustNow alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
joonas-fi committed Mar 10, 2020
1 parent c145cd6 commit ad9a622
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/alertmanager/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ func deduplicateAndRatelimit(
state *amstate.Store,
maxActiveAlerts int,
) []amstate.Alert {
processed := []amstate.Alert{}
filtered := []amstate.Alert{}

activeAlerts := state.ActiveAlerts()

addedJustNow := func() int { return len(filtered) }

for _, alert := range alerts {
// no more "room"?
if len(activeAlerts) >= maxActiveAlerts {
if (len(activeAlerts) + addedJustNow()) >= maxActiveAlerts {
continue
}

Expand All @@ -110,10 +112,10 @@ func deduplicateAndRatelimit(
continue
}

processed = append(processed, alert)
filtered = append(filtered, alert)
}

return processed
return filtered
}

func getMaxFiringAlerts() (int, error) {
Expand Down

0 comments on commit ad9a622

Please sign in to comment.