@@ -65,22 +65,21 @@ func (mc JSONMetricCollector) Collect(ch chan<- prometheus.Metric) {
65
65
floatValue ,
66
66
extractLabels (mc .Logger , mc .Data , m .LabelsJSONPaths )... ,
67
67
)
68
+ } else {
69
+ intValue , err := SanitizeHexIntValue (value )
70
+ if err == nil {
71
+ ch <- prometheus .MustNewConstMetric (
72
+ m .Desc ,
73
+ m .ValueType ,
74
+ float64 (intValue ),
75
+ extractLabels (mc .Logger , mc .Data , m .LabelsJSONPaths )... ,
76
+ )
77
+ } else {
78
+ level .Error (mc .Logger ).Log ("msg" , "Failed to convert extracted value to float64" , "path" , m .KeyJSONPath , "value" , value , "err" , err , "metric" , m .Desc )
79
+ continue
80
+ }
68
81
}
69
82
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
-
84
83
case config .ObjectScrape :
85
84
values , err := extractValue (mc .Logger , mc .Data , m .KeyJSONPath , true )
86
85
if err != nil {
@@ -102,7 +101,8 @@ func (mc JSONMetricCollector) Collect(ch chan<- prometheus.Metric) {
102
101
continue
103
102
}
104
103
105
- if floatValue , err := SanitizeValue (value ); err == nil {
104
+ floatValue , err := SanitizeValue (value )
105
+ if err == nil {
106
106
metric := prometheus .MustNewConstMetric (
107
107
m .Desc ,
108
108
m .ValueType ,
@@ -111,8 +111,18 @@ func (mc JSONMetricCollector) Collect(ch chan<- prometheus.Metric) {
111
111
)
112
112
ch <- timestampMetric (mc .Logger , m , jdata , metric )
113
113
} else {
114
- level .Error (mc .Logger ).Log ("msg" , "Failed to convert extracted value to float64" , "path" , m .ValueJSONPath , "value" , value , "err" , err , "metric" , m .Desc )
115
- continue
114
+ intValue , err := SanitizeHexIntValue (value )
115
+ if err == nil {
116
+ ch <- prometheus .MustNewConstMetric (
117
+ m .Desc ,
118
+ m .ValueType ,
119
+ float64 (intValue ),
120
+ extractLabels (mc .Logger , mc .Data , m .LabelsJSONPaths )... ,
121
+ )
122
+ } else {
123
+ level .Error (mc .Logger ).Log ("msg" , "Failed to convert extracted value to float64" , "path" , m .ValueJSONPath , "value" , value , "err" , err , "metric" , m .Desc )
124
+ continue
125
+ }
116
126
}
117
127
}
118
128
} else {
0 commit comments