@@ -53,15 +53,15 @@ var (
5353 activeDecisionsGauge = prometheus .NewGaugeVec (prometheus.GaugeOpts {
5454 Name : string (activeDecisionsName ),
5555 Help : "The current number of active decisions" ,
56- }, []string {"origin" }) // TODO: additional labels, similar to firewall bouncer?
56+ }, []string {"origin" , "ip_type" })
5757 blockedRequestsCounter = prometheus .NewCounterVec (prometheus.CounterOpts {
5858 Name : string (blockedRequestsCounterName ),
5959 Help : "The total number of requests blocked" ,
60- }, []string {"origin" , "remediation" })
61- processedRequestsCounter = prometheus .NewCounter (prometheus.CounterOpts {
60+ }, []string {"server" , " origin" , "remediation" , "ip_type " })
61+ processedRequestsCounter = prometheus .NewCounterVec (prometheus.CounterOpts {
6262 Name : string (processedRequestsCounterName ),
6363 Help : "The total number of requests handled" ,
64- })
64+ }, [] string { "server" , "ip_type" } )
6565
6666 // TODO: referencing the global metrics from csbouncer may not be the right
6767 // thing to do with how the CrowdSec module operates as part of Caddy. On
@@ -113,32 +113,34 @@ func newMetricsProvider(client *apiclient.ApiClient, metricsRegistry, caddyMetri
113113 Name : "active_decisions" ,
114114 Unit : "ip" ,
115115 Collector : activeDecisionsGauge ,
116- LabelKeys : []string {"origin" },
116+ LabelKeys : []string {"origin" , "ip_type" },
117117 LastValueMap : nil , // absolute value
118118 KeyFunc : func (labels []* model.LabelPair ) string {
119- return getLabelValue (labels , "origin" )
119+ return getLabelValue (labels , "origin" ) + getLabelValue ( labels , "ip_type" )
120120 },
121121 SendToLAPI : true ,
122122 },
123123 blockedRequestsCounterName : {
124124 Name : "dropped" ,
125125 Unit : "request" ,
126126 Collector : blockedRequestsCounter ,
127- LabelKeys : []string {"origin" , "remediation" },
127+ LabelKeys : []string {"server" , " origin" , "remediation" , "ip_type " },
128128 LastValueMap : make (map [string ]float64 ),
129129 KeyFunc : func (labels []* model.LabelPair ) string {
130- return getLabelValue (labels , "origin" ) + getLabelValue (labels , "remediation" )
130+ return getLabelValue (labels , "server" ) + getLabelValue ( labels , " origin" ) + getLabelValue (labels , "remediation" ) + getLabelValue ( labels , "ip_type " )
131131 },
132132 SendToLAPI : true ,
133133 },
134134 processedRequestsCounterName : {
135135 Name : "processed" ,
136136 Unit : "request" ,
137137 Collector : processedRequestsCounter ,
138- LabelKeys : []string {},
138+ LabelKeys : []string {"server" , "ip_type" },
139139 LastValueMap : make (map [string ]float64 ),
140- KeyFunc : func ([]* model.LabelPair ) string { return "" },
141- SendToLAPI : true ,
140+ KeyFunc : func (labels []* model.LabelPair ) string {
141+ return getLabelValue (labels , "server" ) + getLabelValue (labels , "ip_type" )
142+ },
143+ SendToLAPI : true ,
142144 },
143145 totalBouncerCallsName : {
144146 Name : "bouncer_calls" ,
@@ -198,7 +200,7 @@ func newMetricsProvider(client *apiclient.ApiClient, metricsRegistry, caddyMetri
198200 Name : & osName ,
199201 Version : & osVersion ,
200202 },
201- bouncerFeatureFlags : []string {}, // not used in bouncers
203+ bouncerFeatureFlags : []string {}, // not used in bouncers?
202204 logger : logger .With (zap .String ("instance_id" , instanceID )),
203205 instanceID : instanceID ,
204206 }
@@ -229,7 +231,7 @@ func (m *metricsProvider) metricsPayload(now time.Time) (metrics *models.AllMetr
229231 metrics = & models.AllMetrics {
230232 RemediationComponents : []* models.RemediationComponentsMetrics {
231233 {
232- Name : userAgentName , // TODO: verify this is OK to use as-is
234+ Name : userAgentName ,
233235 Type : m .bouncerType ,
234236 BaseMetrics : models.BaseMetrics {
235237 Os : & m .bouncerOS ,
0 commit comments