diff --git a/pipeline/antispam/antispammer.go b/pipeline/antispam/antispammer.go index b5779693d..4a5cbff16 100644 --- a/pipeline/antispam/antispammer.go +++ b/pipeline/antispam/antispammer.go @@ -29,7 +29,7 @@ type Antispammer struct { // antispammer metrics activeMetric prometheus.Gauge - banMetric metric.HeldGaugeVec + banMetric *prometheus.GaugeVec exceptionMetric *prometheus.CounterVec } @@ -57,8 +57,6 @@ func NewAntispammer(o *Options) *Antispammer { zap.Duration("maintenance", o.MaintenanceInterval)) } - banMetric := o.MetricsController.RegisterGaugeVec("antispam_banned", "Source is banned", "source_name") - a := &Antispammer{ unbanIterations: o.UnbanIterations, threshold: o.Threshold, @@ -69,7 +67,10 @@ func NewAntispammer(o *Options) *Antispammer { activeMetric: o.MetricsController.RegisterGauge("antispam_active", "Gauge indicates whether the antispam is enabled", ), - banMetric: o.MetricHolder.AddGaugeVec(banMetric), + banMetric: o.MetricsController.RegisterGaugeVec("antispam_banned", + "Source is banned", + "source_name", + ), exceptionMetric: o.MetricsController.RegisterCounterVec("antispam_exceptions", "How many times an exception match with an event", "name", @@ -157,6 +158,7 @@ func (a *Antispammer) Maintenance() { if x == 0 { delete(a.sources, sourceID) + a.banMetric.DeleteLabelValues(source.name) continue }