AlteredCoder 3 роки тому
батько
коміт
5c8e2a8510
1 змінених файлів з 10 додано та 2 видалено
  1. 10 2
      cmd/crowdsec-cli/utils.go

+ 10 - 2
cmd/crowdsec-cli/utils.go

@@ -319,7 +319,11 @@ func GetParserMetric(url string, itemName string) map[string]map[string]int {
 		}
 		log.Tracef("round %d", idx)
 		for _, m := range fam.Metrics {
-			metric := m.(prom2json.Metric)
+			metric, ok := m.(prom2json.Metric)
+			if !ok {
+				log.Debugf("failed to convert metric to prom2json.Metric")
+				continue
+			}
 			name, ok := metric.Labels["name"]
 			if !ok {
 				log.Debugf("no name in Metric %v", metric.Labels)
@@ -402,7 +406,11 @@ func GetScenarioMetric(url string, itemName string) map[string]int {
 		}
 		log.Tracef("round %d", idx)
 		for _, m := range fam.Metrics {
-			metric := m.(prom2json.Metric)
+			metric, ok := m.(prom2json.Metric)
+			if !ok {
+				log.Debugf("failed to convert metric to prom2json.Metric")
+				continue
+			}
 			name, ok := metric.Labels["name"]
 			if !ok {
 				log.Debugf("no name in Metric %v", metric.Labels)