Skip to content

Commit 2a1204e

Browse files
cmd/alertmanager: add alertmanager_integrations metric (#2117)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
1 parent df1f1c8 commit 2a1204e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cmd/alertmanager/main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ var (
9292
Help: "Number of configured receivers.",
9393
},
9494
)
95+
configuredIntegrations = prometheus.NewGauge(
96+
prometheus.GaugeOpts{
97+
Name: "alertmanager_integrations",
98+
Help: "Number of configured integrations.",
99+
},
100+
)
95101
promlogConfig = promlog.Config{}
96102
)
97103

@@ -100,6 +106,7 @@ func init() {
100106
prometheus.MustRegister(responseSize)
101107
prometheus.MustRegister(clusterEnabled)
102108
prometheus.MustRegister(configuredReceivers)
109+
prometheus.MustRegister(configuredIntegrations)
103110
prometheus.MustRegister(version.NewCollector("alertmanager"))
104111
}
105112

@@ -402,6 +409,7 @@ func run() int {
402409

403410
// Build the map of receiver to integrations.
404411
receivers := make(map[string][]notify.Integration, len(activeReceivers))
412+
var integrationsNum int
405413
for _, rcv := range conf.Receivers {
406414
if _, found := activeReceivers[rcv.Name]; !found {
407415
// No need to build a receiver if no route is using it.
@@ -414,6 +422,7 @@ func run() int {
414422
}
415423
// rcv.Name is guaranteed to be unique across all receivers.
416424
receivers[rcv.Name] = integrations
425+
integrationsNum += len(integrations)
417426
}
418427

419428
inhibitor.Stop()
@@ -430,6 +439,7 @@ func run() int {
430439
peer,
431440
)
432441
configuredReceivers.Set(float64(len(activeReceivers)))
442+
configuredIntegrations.Set(float64(integrationsNum))
433443

434444
api.Update(conf, func(labels model.LabelSet) {
435445
inhibitor.Mutes(labels)

0 commit comments

Comments
 (0)