crowdsecurity / cs-firewall-bouncer

Crowdsec bouncer written in golang for firewalls
MIT License
111 stars 41 forks source link

basic PF prometheus metrics (packets, bytes, banned ip count) #349

Closed mmetc closed 8 months ago

nferch commented 8 months ago

I can confirm this works on my box with the following change. My tables are named crowdsec-blacklists and crowdsec6-blacklists.

--- a/pkg/pf/metrics.go
+++ b/pkg/pf/metrics.go
@@ -19,7 +19,7 @@ type counter struct {
 }

 var (
-       rexpTable   = regexp.MustCompile(`^block .* from <(?P<table>\w+)> .*"$`)
+       rexpTable   = regexp.MustCompile(`^block .* from <(?P<table>[^ ]+)>`)
        rexpMetrics = regexp.MustCompile(`^\s+\[.*Packets: (?P<packets>\d+)\s+Bytes: (?P<bytes>\d+).*\]$`)
 )
mmetc commented 8 months ago

Oh yes, I forgot outside pfsense we use the dash character. Ok. Thanks for testing!