Open
Description
docker-compose log:
json-exporter | time=2025-03-29T12:58:03.636Z level=ERROR source=collector.go:68 msg="Failed to convert extracted value to float64" path={.devices[*]} value="{\"snet_time_ema\":3.141592653589793,\"snet_tries_10mins\":5} {\"snet_time_ema\":4.141592653589793,\"snet_tries_10mins\":3}" err="strconv.ParseFloat: parsing \"{\\\"snet_time_ema\\\":3.141592653589793,\\\"snet_tries_10mins\\\":5} {\\\"snet_time_ema\\\":4.141592653589793,\\\"snet_tries_10mins\\\":3}\": invalid syntax; strconv.ParseFloat: parsing \"{\\\"snet_time_ema\\\":3.141592653589793,\\\"snet_tries_10mins\\\":5} {\\\"snet_time_ema\\\":4.141592653589793,\\\"snet_tries_10mins\\\":3}\": invalid syntax" metric="Desc{fqName: \"snet_metrics\", help: \"snet_metrics\", constLabels: {}, variableLabels: {}}"
This is my json:
{
"devices": [
{
"snet_time_ema": 3.14159265358979,
"snet_tries_10mins": 5
},
{
"snet_time_ema": 4.14159265358979,
"snet_tries_10mins": 3
}
]
}
This is my json_exporter config:
modules:
test_module:
metrics:
- name: snet_metrics
path: '{.devices[*]}'
values:
time_ema: '{.snet_time_ema}'
tries_10mins: '{.snet_tries_10mins}'
And this is my prometheus.yml snippet:
- job_name: 'test_module'
metrics_path: /probe
params:
module: [test_module]
static_configs:
- targets:
- 'http://WANIP:8080/devices'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: json-exporter:7979
Though for faster testing I'm running this inside the json-exporter container instead of waiting up to 60s for prometheus to query it. wget -O- "http://localhost:7979/probe?target=http://WANIP:8080/devices&module=test_module"
I've tried to reduce the json as much as possible using a flask script, as the original comes from a 3rd party API, to try and isolate the issue.
Any idea is welcome!
Metadata
Metadata
Assignees
Labels
No labels