Browse Source

avoid error when prometheus gives scientific notation

Thibault bui Koechlin 5 năm trước cách đây
mục cha
commit
ff7f8cf6bd
1 tập tin đã thay đổi với 2 bổ sung1 xóa
  1. 2 1
      cmd/crowdsec-cli/metrics.go

+ 2 - 1
cmd/crowdsec-cli/metrics.go

@@ -62,10 +62,11 @@ func ShowPrometheus(url string) {
 				log.Debugf("no source in Metric")
 				log.Debugf("no source in Metric")
 			}
 			}
 			value := m.(prom2json.Metric).Value
 			value := m.(prom2json.Metric).Value
-			ival, err := strconv.Atoi(value)
+			fval, err := strconv.ParseFloat(value, 32)
 			if err != nil {
 			if err != nil {
 				log.Errorf("Unexpected int value %s : %s", value, err)
 				log.Errorf("Unexpected int value %s : %s", value, err)
 			}
 			}
+			ival := int(fval)
 			switch fam.Name {
 			switch fam.Name {
 			/*buckets*/
 			/*buckets*/
 			case "cs_bucket_create":
 			case "cs_bucket_create":