Skip to content

Commit 650d43c

Browse files
committed
Fix marker to rely on iterface
Signed-off-by: SungJin1212 <[email protected]>
1 parent 6ce7ac3 commit 650d43c

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

pkg/alertmanager/alertmanager.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ type Alertmanager struct {
103103
persister *statePersister
104104
nflog *nflog.Log
105105
silences *silence.Silences
106-
marker *types.MemMarker
106+
alertMarker types.AlertMarker
107+
groupMarker types.GroupMarker
107108
alerts *mem.Alerts
108109
dispatcher *dispatch.Dispatcher
109110
inhibitor *inhibit.Inhibitor
@@ -222,7 +223,9 @@ func New(cfg *Config, reg *prometheus.Registry) (*Alertmanager, error) {
222223
am.nflog.Maintenance(maintenancePeriod, notificationFile, am.stop, nil)
223224
am.wg.Done()
224225
}()
225-
am.marker = types.NewMarker(am.registry)
226+
memMarker := types.NewMarker(reg)
227+
am.alertMarker = memMarker
228+
am.groupMarker = memMarker
226229

227230
silencesFile := filepath.Join(cfg.TenantDataDir, silencesSnapshot)
228231
am.silences, err = silence.New(silence.Options{
@@ -268,16 +271,16 @@ func New(cfg *Config, reg *prometheus.Registry) (*Alertmanager, error) {
268271
if am.cfg.Limits != nil {
269272
callback = newAlertsLimiter(am.cfg.UserID, am.cfg.Limits, reg)
270273
}
271-
am.alerts, err = mem.NewAlerts(context.Background(), am.marker, am.cfg.GCInterval, callback, util_log.GoKitLogToSlog(am.logger), am.registry)
274+
am.alerts, err = mem.NewAlerts(context.Background(), am.alertMarker, am.cfg.GCInterval, callback, util_log.GoKitLogToSlog(am.logger), am.registry)
272275
if err != nil {
273276
return nil, fmt.Errorf("failed to create alerts: %v", err)
274277
}
275278

276279
am.api, err = api.New(api.Options{
277280
Alerts: am.alerts,
278281
Silences: am.silences,
279-
AlertStatusFunc: am.marker.Status,
280-
GroupMutedFunc: am.marker.Muted,
282+
AlertStatusFunc: am.alertMarker.Status,
283+
GroupMutedFunc: am.groupMarker.Muted,
281284
// Cortex should not expose cluster information back to its tenants.
282285
Peer: &NilPeer{},
283286
Registry: am.registry,
@@ -360,7 +363,7 @@ func (am *Alertmanager) ApplyConfig(userID string, conf *config.Config, rawCfg s
360363
am.dispatcher.Stop()
361364
}
362365

363-
am.inhibitor = inhibit.NewInhibitor(am.alerts, conf.InhibitRules, am.marker, util_log.GoKitLogToSlog(log.With(am.logger, "component", "inhibitor")))
366+
am.inhibitor = inhibit.NewInhibitor(am.alerts, conf.InhibitRules, am.alertMarker, util_log.GoKitLogToSlog(log.With(am.logger, "component", "inhibitor")))
364367

365368
waitFunc := clusterWait(am.state.Position, am.cfg.PeerTimeout)
366369

@@ -403,9 +406,9 @@ func (am *Alertmanager) ApplyConfig(userID string, conf *config.Config, rawCfg s
403406
integrationsMap,
404407
waitFunc,
405408
am.inhibitor,
406-
silence.NewSilencer(am.silences, am.marker, util_log.GoKitLogToSlog(am.logger)),
409+
silence.NewSilencer(am.silences, am.alertMarker, util_log.GoKitLogToSlog(am.logger)),
407410
timeinterval.NewIntervener(timeIntervals),
408-
am.marker,
411+
am.groupMarker,
409412
am.nflog,
410413
am.state,
411414
)
@@ -414,7 +417,7 @@ func (am *Alertmanager) ApplyConfig(userID string, conf *config.Config, rawCfg s
414417
am.alerts,
415418
dispatch.NewRoute(conf.Route, nil),
416419
pipeline,
417-
am.marker,
420+
am.groupMarker,
418421
timeoutFunc,
419422
&dispatcherLimits{tenant: am.cfg.UserID, limits: am.cfg.Limits},
420423
util_log.GoKitLogToSlog(log.With(am.logger, "component", "dispatcher")),

0 commit comments

Comments
 (0)