Alerting: Skip setting up clustering in remote primary/only modes (#88968)

* Alerting: Skip setting up clustering in remote primary mode

* Update pkg/services/ngalert/notifier/multiorg_alertmanager.go

Co-authored-by: Steve Simpson <steve.simpson@grafana.com>

---------

Co-authored-by: Steve Simpson <steve.simpson@grafana.com>
This commit is contained in:
Santiago 2024-06-10 13:51:11 +02:00 committed by GitHub
parent 35d0597367
commit e15e40fbd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 2 deletions

View File

@ -177,6 +177,7 @@ func (ng *AlertNG) init() error {
ng.Log.Debug("Starting Grafana with remote only mode enabled")
m := ng.Metrics.GetRemoteAlertmanagerMetrics()
m.Info.WithLabelValues(metrics.ModeRemoteOnly).Set(1)
ng.Cfg.UnifiedAlerting.SkipClustering = true
// This function will be used by the MOA to create new Alertmanagers.
override := notifier.WithAlertmanagerOverride(func(_ notifier.OrgAlertmanagerFactory) notifier.OrgAlertmanagerFactory {
@ -203,6 +204,7 @@ func (ng *AlertNG) init() error {
case remotePrimary:
ng.Log.Warn("Only remote secondary mode is supported at the moment, falling back to remote secondary")
// TODO: Skip setting up clustering with ng.Cfg.UnifiedAlerting.SkipClustering = true
fallthrough
case remoteSecondary:

View File

@ -142,8 +142,12 @@ func NewMultiOrgAlertmanager(
peer: &NilPeer{},
}
if err := moa.setupClustering(cfg); err != nil {
return nil, err
if cfg.UnifiedAlerting.SkipClustering {
l.Info("Skipping setting up clustering for MOA")
} else {
if err := moa.setupClustering(cfg); err != nil {
return nil, err
}
}
// Set up the default per tenant Alertmanager factory.

View File

@ -98,6 +98,7 @@ type UnifiedAlertingSettings struct {
DefaultRuleEvaluationInterval time.Duration
Screenshots UnifiedAlertingScreenshotSettings
ReservedLabels UnifiedAlertingReservedLabelSettings
SkipClustering bool
StateHistory UnifiedAlertingStateHistorySettings
RemoteAlertmanager RemoteAlertmanagerSettings
// MaxStateSaveConcurrency controls the number of goroutines (per rule) that can save alert state in parallel.