@@ -57,19 +57,30 @@ func (mc JSONMetricCollector) Collect(ch chan<- prometheus.Metric) {
5757 continue
5858 }
5959
60- if floatValue , err := SanitizeValue (value ); err == nil {
61- metric := prometheus .MustNewConstMetric (
60+ floatValue , err := SanitizeValue (value )
61+ if err == nil {
62+ ch <- prometheus .MustNewConstMetric (
6263 m .Desc ,
6364 m .ValueType ,
6465 floatValue ,
6566 extractLabels (mc .Logger , mc .Data , m .LabelsJSONPaths )... ,
6667 )
67- ch <- timestampMetric (mc .Logger , m , mc .Data , metric )
68- } else {
69- level .Error (mc .Logger ).Log ("msg" , "Failed to convert extracted value to float64" , "path" , m .KeyJSONPath , "value" , value , "err" , err , "metric" , m .Desc )
70- continue
7168 }
7269
70+ intValue , err := SanitizeHexIntValue (value )
71+ if err == nil {
72+ ch <- prometheus .MustNewConstMetric (
73+ m .Desc ,
74+ prometheus .UntypedValue ,
75+ float64 (intValue ),
76+ extractLabels (mc .Logger , mc .Data , m .LabelsJSONPaths )... ,
77+ )
78+ }
79+
80+
81+ level .Error (mc .Logger ).Log ("msg" , "Failed to convert extracted value to float64" , "path" , m .KeyJSONPath , "value" , value , "err" , err , "metric" , m .Desc )
82+ continue
83+
7384 case config .ObjectScrape :
7485 values , err := extractValue (mc .Logger , mc .Data , m .KeyJSONPath , true )
7586 if err != nil {
0 commit comments