Add Opsgenie alias field for alert deduplication#1292
Open
cairon-ab wants to merge 1 commit intofluxcd:mainfrom
Open
Add Opsgenie alias field for alert deduplication#1292cairon-ab wants to merge 1 commit intofluxcd:mainfrom
cairon-ab wants to merge 1 commit intofluxcd:mainfrom
Conversation
Set the alias field on Opsgenie alerts using a SHA-256 hash of the involved object's Kind, Namespace, Name, and event Reason. This allows Opsgenie to deduplicate repeated alerts for the same source instead of creating new pages for each firing. Fixes fluxcd#460 Signed-off-by: Cairon <cairon-ab@users.noreply.github.com>
Comment on lines
+112
to
+115
| event.InvolvedObject.Kind, | ||
| event.InvolvedObject.Namespace, | ||
| event.InvolvedObject.Name, | ||
| event.Reason, |
Member
There was a problem hiding this comment.
This will cause alerts from multiple clusters to aggregate under the same incident since all clusters have Kustomization/flux-system/flux-system, which is a major breaking change. Adding the Alert Provider UID to the checksum would ensure each cluster gets a dedicated incident.
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.
Summary
Set the
aliasfield on Opsgenie alerts using a SHA-256 hash of the involved object's Kind, Namespace, Name, and event Reason. This allows Opsgenie to deduplicate repeated alerts for the same source instead of creating new pages for each firing.Changes
Aliasfield toOpsgenieAlertstruct withjson:"alias,omitempty"generateOpsgenieAlias()function that creates a deterministic SHA-256 hash from the event'sInvolvedObject.Kind,InvolvedObject.Namespace,InvolvedObject.Name, andReasonPost()so every alert carries a stable aliasTestOpsgenie_PostAlias(verifies alias in HTTP payload across multiple scenarios) andTestGenerateOpsgenieAlias(determinism, length, uniqueness)Why
Currently, Opsgenie creates a new alert for every notification event, even when it's for the same object and reason. The Opsgenie Alert API supports an
aliasfield that acts as a deduplication key — alerts with the same alias are grouped as a single incident.By hashing
Kind/Namespace/Name/Reason, we ensure:ReconciliationFailedvsHealthCheckFailed) create separate alertsFixes #460