@@ -29,7 +29,7 @@ type Antispammer struct {
2929
3030 // antispammer metrics
3131 activeMetric prometheus.Gauge
32- banMetric metric. HeldGaugeVec
32+ banMetric * prometheus. GaugeVec
3333 exceptionMetric * prometheus.CounterVec
3434}
3535
@@ -57,8 +57,6 @@ func NewAntispammer(o *Options) *Antispammer {
5757 zap .Duration ("maintenance" , o .MaintenanceInterval ))
5858 }
5959
60- banMetric := o .MetricsController .RegisterGaugeVec ("antispam_banned" , "Source is banned" , "source_name" )
61-
6260 a := & Antispammer {
6361 unbanIterations : o .UnbanIterations ,
6462 threshold : o .Threshold ,
@@ -69,7 +67,10 @@ func NewAntispammer(o *Options) *Antispammer {
6967 activeMetric : o .MetricsController .RegisterGauge ("antispam_active" ,
7068 "Gauge indicates whether the antispam is enabled" ,
7169 ),
72- banMetric : o .MetricHolder .AddGaugeVec (banMetric ),
70+ banMetric : o .MetricsController .RegisterGaugeVec ("antispam_banned" ,
71+ "Source is banned" ,
72+ "source_name" ,
73+ ),
7374 exceptionMetric : o .MetricsController .RegisterCounterVec ("antispam_exceptions" ,
7475 "How many times an exception match with an event" ,
7576 "name" ,
@@ -157,6 +158,7 @@ func (a *Antispammer) Maintenance() {
157158
158159 if x == 0 {
159160 delete (a .sources , sourceID )
161+ a .banMetric .DeleteLabelValues (source .name )
160162 continue
161163 }
162164
0 commit comments