Alerting: Add metric for inhibition rules (#81119)

This commit adds a metric for the number of inhibition rules.
It matches the metric added upstream in #3681.
This commit is contained in:
George Robinson
2024-01-23 19:43:17 +00:00
committed by GitHub
parent 2607528b52
commit 05d858635c
3 changed files with 14 additions and 7 deletions

View File

@@ -73,10 +73,11 @@ type AlertmanagerAggregatedMetrics struct {
registries *metrics.TenantRegistries
// metrics gather from the in-house "Alertmanager" directly.
numReceivedAlerts *prometheus.Desc
numInvalidAlerts *prometheus.Desc
configuredReceivers *prometheus.Desc
configuredIntegrations *prometheus.Desc
numReceivedAlerts *prometheus.Desc
numInvalidAlerts *prometheus.Desc
configuredReceivers *prometheus.Desc
configuredIntegrations *prometheus.Desc
configuredInhibitionRules *prometheus.Desc
// exported metrics, gathered from Alertmanager PipelineBuilder
numNotifications *prometheus.Desc
@@ -141,6 +142,10 @@ func NewAlertmanagerAggregatedMetrics(registries *metrics.TenantRegistries) *Ale
fmt.Sprintf("%s_%s_alertmanager_integrations", Namespace, Subsystem),
"Number of configured receivers.",
[]string{"org", "type"}, nil),
configuredInhibitionRules: prometheus.NewDesc(
fmt.Sprintf("%s_%s_alertmanager_inhibition_rules", Namespace, Subsystem),
"Number of configured inhibition rules.",
[]string{"org"}, nil),
numNotifications: prometheus.NewDesc(
fmt.Sprintf("%s_%s_notifications_total", Namespace, Subsystem),
@@ -270,6 +275,7 @@ func (a *AlertmanagerAggregatedMetrics) Describe(out chan<- *prometheus.Desc) {
out <- a.numInvalidAlerts
out <- a.configuredReceivers
out <- a.configuredIntegrations
out <- a.configuredInhibitionRules
out <- a.numNotifications
out <- a.numFailedNotifications
@@ -314,6 +320,7 @@ func (a *AlertmanagerAggregatedMetrics) Collect(out chan<- prometheus.Metric) {
data.SendSumOfCountersPerTenant(out, a.numInvalidAlerts, "alertmanager_alerts_invalid_total")
data.SendSumOfGaugesPerTenantWithLabels(out, a.configuredReceivers, "grafana_alerting_alertmanager_receivers", "state")
data.SendSumOfGaugesPerTenantWithLabels(out, a.configuredIntegrations, "grafana_alerting_alertmanager_integrations", "type")
data.SendSumOfGaugesPerTenant(out, a.configuredInhibitionRules, "grafana_alerting_alertmanager_inhibition_rules")
data.SendSumOfCountersPerTenant(out, a.numNotifications, "alertmanager_notifications_total", metrics.WithLabels("integration"), metrics.WithSkipZeroValueMetrics)
data.SendSumOfCountersPerTenant(out, a.numFailedNotifications, "alertmanager_notifications_failed_total", metrics.WithLabels("integration"), metrics.WithSkipZeroValueMetrics)