json_exporter
json_exporter copied to clipboard
Failed to convert extracted value to float64
my json looks like:
{
"execution_status": {
"status": "ok",
"last_execution_date": "2021-11-19T09:14:47.819Z"
}
}
and config.yml:
---
metrics:
- name: status
type: value
path: "{.execution_status.status}"
result is:
ts=2021-11-19T09:21:51.263Z caller=level.go:63 level=error msg="Failed to convert extracted value to float64" path={.execution_status.status} value=ok err="strconv.ParseFloat: parsing \"ok\": invalid syntax; strconv.ParseFloat: parsing \"ok\": invalid syntax" metric="Desc{fqName: \"status\", help: \"status\", constLabels: {}, variableLabels: []}"
What am I doing wrong? Thanks!
@jhoustek23
The exporter tries to map "ok"
to a number, this is obviously not working
in order to get a string out you have to use it as a label, e.g.:
metrics:
- name: execution_status
type: object
path: "{.execution_status}"
labels:
status: '{.status}'
values:
status: 1
This should result in the following metrics:
execution_status{staus="ok"} 1
thank you! its working
Another solution for this can be found here - https://github.com/prometheus-community/json_exporter/issues/186#issuecomment-1328156005. I will close this issue since it has already been resolved for OP.