Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to convert extracted value to float64 #134

Closed
jhoustek23 opened this issue Nov 19, 2021 · 3 comments
Closed

Failed to convert extracted value to float64 #134

jhoustek23 opened this issue Nov 19, 2021 · 3 comments

Comments

@jhoustek23
Copy link

jhoustek23 commented Nov 19, 2021

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!

@david-loe
Copy link

@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

@jhoustek23
Copy link
Author

thank you! its working

@rustycl0ck
Copy link
Member

Another solution for this can be found here - #186 (comment).
I will close this issue since it has already been resolved for OP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants