You've already forked alertmanager
mirror of
https://github.com/prometheus/alertmanager.git
synced 2026-10-23 08:48:56 +03:00
Alert fingerprints are calculated once in the API v2 POST handler, after removeEmptyLabels and validation, while the alert is still owned by a single goroutine. Merge copies the younger alert by value, so the cache is carried over. Fingerprint() falls back to hashing the labels when the cache is zero. labelset.LabelSet keeps a private cached fingerprint set via New() but can be built also from a plain model.LabelSet if needed. Silencer.Mutes and Inhibitor.Mutes hashed the full label set on every call, per alert, per pipeline run, only to obtain a cache key that the alert already knows. Change the Muter interface (and MuteFunc, the API setAlertStatus callback and the reloader) to take a labelset.LabelSet, which carries the alert's fingerprint when known, and add Alert.LabelSet() to build one from an alert. MuteStage and the v2 API status prediction now pass a.LabelSet(), so both muters reuse the fingerprint cached at ingestion. Callers that only have plain labels use labelset.FromModel(), which falls back to hashing. Signed-off-by: Guido Trotter <guido@hudson-trading.com>