Skip to content

Commit

Permalink
alertmanager: Sync metric documentation from upstream (#10470)
Browse files Browse the repository at this point in the history
* Update metric docs from upstream

* Suppress md5 since we document safety
  • Loading branch information
alexweav authored Jan 17, 2025
1 parent ea9768a commit a78d78c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pkg/alertmanager/alertmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func New(cfg *Config, reg *prometheus.Registry) (*Alertmanager, error) {
maintenanceStop: make(chan struct{}),
configHashMetric: promauto.With(reg).NewGauge(prometheus.GaugeOpts{
Name: "alertmanager_config_hash",
Help: "Hash of the currently loaded alertmanager configuration.",
Help: "Hash of the currently loaded alertmanager configuration. Note that this is not a cryptographically strong hash.",
}),

rateLimitedNotifications: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
Expand Down Expand Up @@ -764,7 +764,7 @@ func buildReceiverIntegrations(nc config.Receiver, tmpl *template.Template, fire
}

func md5HashAsMetricValue(data []byte) float64 {
sum := md5.Sum(data)
sum := md5.Sum(data) //nolint:gosec
// We only want 48 bits as a float64 only has a 53 bit mantissa.
smallSum := sum[0:6]
var bytes = make([]byte, 8)
Expand Down
2 changes: 1 addition & 1 deletion pkg/alertmanager/alertmanager_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func newAlertmanagerMetrics(logger log.Logger) *alertmanagerMetrics {
[]string{"user", "state"}, nil),
configHashValue: prometheus.NewDesc(
"cortex_alertmanager_config_hash",
"Hash of the currently loaded alertmanager configuration.",
"Hash of the currently loaded alertmanager configuration. Note that this is not a cryptographically strong hash.",
[]string{"user"}, nil),
partialMerges: prometheus.NewDesc(
"cortex_alertmanager_partial_state_merges_total",
Expand Down
8 changes: 4 additions & 4 deletions pkg/alertmanager/alertmanager_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestAlertmanagerMetricsStore(t *testing.T) {
cortex_alertmanager_alerts_received_total{user="user1"} 10
cortex_alertmanager_alerts_received_total{user="user2"} 100
cortex_alertmanager_alerts_received_total{user="user3"} 1000
# HELP cortex_alertmanager_config_hash Hash of the currently loaded alertmanager configuration.
# HELP cortex_alertmanager_config_hash Hash of the currently loaded alertmanager configuration. Note that this is not a cryptographically strong hash.
# TYPE cortex_alertmanager_config_hash gauge
cortex_alertmanager_config_hash{user="user1"} 0
cortex_alertmanager_config_hash{user="user2"} 0
Expand Down Expand Up @@ -389,7 +389,7 @@ func TestAlertmanagerMetricsRemoval(t *testing.T) {
cortex_alertmanager_alerts_received_total{user="user2"} 100
cortex_alertmanager_alerts_received_total{user="user3"} 1000
# HELP cortex_alertmanager_config_hash Hash of the currently loaded alertmanager configuration.
# HELP cortex_alertmanager_config_hash Hash of the currently loaded alertmanager configuration. Note that this is not a cryptographically strong hash.
# TYPE cortex_alertmanager_config_hash gauge
cortex_alertmanager_config_hash{user="user1"} 0
cortex_alertmanager_config_hash{user="user2"} 0
Expand Down Expand Up @@ -720,7 +720,7 @@ func TestAlertmanagerMetricsRemoval(t *testing.T) {
cortex_alertmanager_alerts_received_total{user="user1"} 10
cortex_alertmanager_alerts_received_total{user="user2"} 100
# HELP cortex_alertmanager_config_hash Hash of the currently loaded alertmanager configuration.
# HELP cortex_alertmanager_config_hash Hash of the currently loaded alertmanager configuration. Note that this is not a cryptographically strong hash.
# TYPE cortex_alertmanager_config_hash gauge
cortex_alertmanager_config_hash{user="user1"} 0
cortex_alertmanager_config_hash{user="user2"} 0
Expand Down Expand Up @@ -987,7 +987,7 @@ func populateAlertmanager(base float64) *prometheus.Registry {
reg := prometheus.NewRegistry()
promauto.With(reg).NewGauge(prometheus.GaugeOpts{
Name: "alertmanager_config_hash",
Help: "Hash of the currently loaded alertmanager configuration.",
Help: "Hash of the currently loaded alertmanager configuration. Note that this is not a cryptographically strong hash.",
})

s := newSilenceMetrics(reg)
Expand Down

0 comments on commit a78d78c

Please sign in to comment.