Skip to content

Commit 6cb836f

Browse files
committed
jsonexporter/scraper: fix bool support
Signed-off-by: David DR <[email protected]>
1 parent 2643853 commit 6cb836f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

jsonexporter/scraper.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ func (obsc *ObjectScraper) Scrape(data []byte, reg *harness.MetricRegistry) erro
209209
}
210210

211211
var value float64
212+
var boolValue bool
212213
switch firstResult.Type {
213214
case jsonpath.JsonNumber:
214215
value, err = obsc.parseValue(firstResult.Value)
@@ -217,6 +218,12 @@ func (obsc *ObjectScraper) Scrape(data []byte, reg *harness.MetricRegistry) erro
217218
value, err = obsc.parseValue(firstResult.Value[1 : len(firstResult.Value)-1])
218219
case jsonpath.JsonNull:
219220
value = math.NaN()
221+
case jsonpath.JsonBool:
222+
if boolValue, err = strconv.ParseBool(string(firstResult.Value)); boolValue {
223+
value = 1.0
224+
} else {
225+
value = 0.0
226+
}
220227
default:
221228
log.Warnf("skipping not numerical result;path:<%v>,value:<%s>",
222229
obsc.valueJsonPath, result.Value)

0 commit comments

Comments
 (0)