@@ -15,6 +15,7 @@ import (
15
15
"github.com/crowdsecurity/go-cs-lib/trace"
16
16
17
17
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
18
+ "github.com/crowdsecurity/crowdsec/pkg/metrics"
18
19
)
19
20
20
21
func showMetrics (prometheusURL string , hub * cwhub.Hub , hubItem * cwhub.Item , wantColor string ) error {
@@ -102,36 +103,27 @@ func getParserMetric(url string, itemName string) (map[string]map[string]int, er
102
103
ival := int (fval )
103
104
104
105
switch fam .Name {
105
- case "cs_reader_hits_total" :
106
- if _ , ok := stats [source ]; ! ok {
107
- stats [source ] = make (map [string ]int )
108
- stats [source ]["parsed" ] = 0
109
- stats [source ]["reads" ] = 0
110
- stats [source ]["unparsed" ] = 0
111
- stats [source ]["hits" ] = 0
112
- }
113
- stats [source ]["reads" ] += ival
114
- case "cs_parser_hits_ok_total" :
106
+ case metrics .GlobalParserHitsOkMetricName :
115
107
if _ , ok := stats [source ]; ! ok {
116
108
stats [source ] = make (map [string ]int )
117
109
}
118
110
stats [source ]["parsed" ] += ival
119
- case "cs_parser_hits_ko_total" :
111
+ case metrics . GlobalParserHitsKoMetricName :
120
112
if _ , ok := stats [source ]; ! ok {
121
113
stats [source ] = make (map [string ]int )
122
114
}
123
115
stats [source ]["unparsed" ] += ival
124
- case "cs_node_hits_total" :
116
+ case metrics . NodesHitsMetricName :
125
117
if _ , ok := stats [source ]; ! ok {
126
118
stats [source ] = make (map [string ]int )
127
119
}
128
120
stats [source ]["hits" ] += ival
129
- case "cs_node_hits_ok_total" :
121
+ case metrics . NodesHitsOkMetricName :
130
122
if _ , ok := stats [source ]; ! ok {
131
123
stats [source ] = make (map [string ]int )
132
124
}
133
125
stats [source ]["parsed" ] += ival
134
- case "cs_node_hits_ko_total" :
126
+ case metrics . NodesHitsKoMetricName :
135
127
if _ , ok := stats [source ]; ! ok {
136
128
stats [source ] = make (map [string ]int )
137
129
}
@@ -194,15 +186,15 @@ func getScenarioMetric(url string, itemName string) (map[string]int, error) {
194
186
ival := int (fval )
195
187
196
188
switch fam .Name {
197
- case "cs_bucket_created_total" :
189
+ case metrics . BucketsInstantiationMetricName :
198
190
stats ["instantiation" ] += ival
199
- case "cs_buckets" :
191
+ case metrics . BucketsCurrentCountMetricName :
200
192
stats ["curr_count" ] += ival
201
- case "cs_bucket_overflowed_total" :
193
+ case metrics . BucketsOverflowMetricName :
202
194
stats ["overflow" ] += ival
203
- case "cs_bucket_poured_total" :
195
+ case metrics . BucketPouredMetricName :
204
196
stats ["pour" ] += ival
205
- case "cs_bucket_underflowed_total" :
197
+ case metrics . BucketsUnderflowMetricName :
206
198
stats ["underflow" ] += ival
207
199
default :
208
200
continue
0 commit comments