mirror of
https://github.com/prometheus-community/json_exporter
synced 2024-12-24 15:33:59 +00:00
Merge pull request #17 from WilliButz/add-bool-support
jsonexporter/scraper: add bool support
This commit is contained in:
commit
c483776514
@ -80,6 +80,7 @@ func (vs *ValueScraper) Scrape(data []byte, reg *harness.MetricRegistry) error {
|
||||
isFirst = false
|
||||
|
||||
var value float64
|
||||
var boolValue bool
|
||||
var err error
|
||||
switch result.Type {
|
||||
case jsonpath.JsonNumber:
|
||||
@ -89,6 +90,12 @@ func (vs *ValueScraper) Scrape(data []byte, reg *harness.MetricRegistry) error {
|
||||
value, err = vs.parseValue(result.Value[1 : len(result.Value)-1])
|
||||
case jsonpath.JsonNull:
|
||||
value = math.NaN()
|
||||
case jsonpath.JsonBool:
|
||||
if boolValue, err = strconv.ParseBool(string(result.Value)); boolValue {
|
||||
value = 1
|
||||
} else {
|
||||
value = 0
|
||||
}
|
||||
default:
|
||||
log.Warnf("skipping not numerical result;path:<%v>,value:<%s>",
|
||||
vs.valueJsonPath, result.Value)
|
||||
|
Loading…
Reference in New Issue
Block a user