@@ -65,30 +65,31 @@ func New(cfg *Config) (*Alertmanager, error) {
65
65
stop : make (chan struct {}),
66
66
}
67
67
68
+ // TODO(cortex): Build a registry that can merge metrics from multiple users.
69
+ // For now, these metrics are ignored, as we can't register the same
70
+ // metric twice with a single registry.
71
+ localRegistry := prometheus .NewRegistry ()
72
+
68
73
am .wg .Add (1 )
69
74
nflogID := fmt .Sprintf ("nflog:%s" , cfg .UserID )
70
75
var err error
71
76
am .nflog , err = nflog .New (
72
77
nflog .WithRetention (cfg .Retention ),
73
78
nflog .WithSnapshot (filepath .Join (cfg .DataDir , nflogID )),
74
79
nflog .WithMaintenance (notificationLogMaintenancePeriod , am .stop , am .wg .Done ),
75
- // TODO(cortex): Build a registry that can merge metrics from multiple users.
76
- // For now, these metrics are ignored, as we can't register the same
77
- // metric twice with a single registry.
78
- nflog .WithMetrics (prometheus .NewRegistry ()),
80
+ nflog .WithMetrics (localRegistry ),
79
81
nflog .WithLogger (log .With (am .logger , "component" , "nflog" )),
80
82
)
81
83
if err != nil {
82
84
return nil , fmt .Errorf ("failed to create notification log: %v" , err )
83
85
}
86
+ if cfg .Peer != nil {
87
+ c := cfg .Peer .AddState ("nfl:" + cfg .UserID , am .nflog , localRegistry )
88
+ am .nflog .SetBroadcast (c .Broadcast )
89
+ }
84
90
85
91
am .marker = types .NewMarker ()
86
92
87
- // TODO(cortex): Build a registry that can merge metrics from multiple users.
88
- // For now, these metrics are ignored, as we can't register the same
89
- // metric twice with a single registry.
90
- localRegistry := prometheus .NewRegistry ()
91
-
92
93
silencesID := fmt .Sprintf ("silences:%s" , cfg .UserID )
93
94
am .silences , err = silence .New (silence.Options {
94
95
SnapshotFile : filepath .Join (cfg .DataDir , silencesID ),
0 commit comments