Repository navigation
Conversation
The Prometheus notifier does not retry: it logs the error returned by the Do option and moves on to the next batch, so a notification the Alertmanager failed to accept is dropped and its alert is not delivered until the rule group is evaluated again. Two of those failures recover on a second attempt: the Alertmanager closing a keep-alive connection it considers idle just as the ruler reuses it, and an Alertmanager replying 503 while it shuts down with the connection still pinned to it. Retry a notification that failed with a transport error or a 5xx response, up to -ruler.notification.backoff-retries times, dropping the idle connections of the tenant's client first so that the next attempt opens a new connection. A 4xx response is not retried, the Alertmanager rejects the request however many times it is sent. The retries are disabled by default, so the behaviour does not change unless they are configured, and they are always bounded by the context of the notification, which carries -ruler.notification-timeout. Signed-off-by: Ben Ye <benye@amazon.com>
yeya24
force-pushed
the
ruler-notification-retry
branch
from
November 2, 2026 06:39
18898aa to
67a4614
Compare
danielblando
approved these changes
Nov 2, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does:
The Prometheus notifier the ruler embeds does not retry.
sendOnecalls theDooption once, and the caller only logs the error and adds to the error counter
before moving on to the next batch, so a notification the Alertmanager fails to
accept is dropped: its alert is not delivered until the rule group is evaluated
again.
Two of those failures recover on a second attempt, and both are routine when the
ruler keeps connections alive to the Alertmanager:
it for a POST, and the ruler logs
error occurred while sending alerts ... EOF.The notifier client's
IdleConnTimeoutis independent of the server's idletimeout, so the race repeats for as long as both are running. This is Ruler reports an error EOF when sending alert to alertmanager #4958,
also reported in cortex ruler send alert to alertmanager ERROR EOF #3009 and asked about in Guidance on Ruler -> AlertManager intermittent reachability #4355.
final_sleeplasts, becauseMultitenantAlertmanager.ServeHTTPreturns earlywhile the service is not
Running(pkg/alertmanager/multitenant.go) and doesnot forward the alerts to another replica. A keep-alive connection pinned to
that instance keeps getting 503 until it is replaced, even though healthy
replicas are behind the same address.
This PR retries such a notification instead of dropping it:
deadline being exceeded, and a 5xx response are retried. A 4xx response is not:
the Alertmanager rejects the request however many times it is sent.
attempt opens a new connection. That is also how it reaches another instance
when the Alertmanagers are behind a load balancer.
GetBodyon every attempt.POST /api/v2/alertsis idempotent, the Alertmanager merges the alerts by fingerprint.
-ruler.notification-timeout, and they delay the other notifications of the sametenant, which is why the flag description asks for a small number.
Configuration
Disabled by default, so nothing changes unless it is configured:
-ruler.notification.backoff-retries0, the retries are disabled-ruler.notification.backoff-min-period100ms-ruler.notification.backoff-max-period1sA new per-user counter,
cortex_ruler_notification_retries_total, counts theretried notifications.
One thing worth a look in review: the config reuses
backoff.Config, butmax_retries = 0disables the retries here instead of making them infinite, sothat the default does not change the behaviour of the ruler.
transport.Retryreads a retry count the same way. That is why the three flags are registered with
their own descriptions instead of calling
backoff.Config.RegisterFlagsWithPrefix,which would default the count to 10 and document it as the generic backoff count.
Happy to move to a separate
-ruler.notification-retry-enabledflag and leavebackoff.Configwith its usual semantics if that reads better.Which issue(s) this PR fixes:
Related to #4958
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]docs/configuration/v1-guarantees.mdupdated if this PR introduces experimental flags