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

Values could not be parsed to Float64 #3

Open
pete-leese opened this issue Mar 12, 2018 · 16 comments
Open

Values could not be parsed to Float64 #3

pete-leese opened this issue Mar 12, 2018 · 16 comments

Comments

@pete-leese
Copy link

I have set this up but struggling to get it return any data from my feed.

console output states the following:

2018/03/12 11:39:10 Found value 17.8

but when hitting the URL it just displays:

Values could not be parsed to Float64

The json I am trying to query is as follows:
{
"isValid":true,
"validationRuleErrors":[],
"httpStatusCode":200,
"genericErrorMessage":null,
"data":{
"version":"17.8"
}
}

I am able to read httpStatusCode OK, however for other values such as isValid etc... this throws the same error.

Example query:

http://XXXX:9116/probe?target=http://XXXX.com/api/version/?json=%7B%22key%22:%22value%22&jsonpath=$.data.version

Secondly, is there a way to change the metric label from just outputting "value" to give each of the above json keys a unique identifier.

Any ideas ?

@SPFZ
Copy link

SPFZ commented Mar 17, 2018

To your second question, you can use this in your scrape config to overwrite the metric name (which is just a hidden label called __name__):


metric_relabel_configs:
      - source_labels: [__name__]
        regex: value
        target_label: __name__
        replacement: custom_metric_name

This overwrites "value" with "custom_metric_name".

@pete-leese
Copy link
Author

Thanks for that @spampel

If only it would work for me 😂 👍🏻

@SPFZ
Copy link

SPFZ commented Mar 18, 2018

I found the problem, it does not parse strings to float. There is a pull request (#1) fixing some of the problems with this exporter, including yours.

You can use this instead and it shoudl work: https://github.com/huiyiqun/json-exporter

I tested this and it should solve your problem.

@pete-leese
Copy link
Author

This is great to hear. Will get this installed and setup tomorrow. Thanks !

@pete-leese
Copy link
Author

Hi @spzf, is there a method for querying more than one key from a single source that can be picked up by Prometheus or do I have to setup a url per metric I wish to digest from each json source?

@pete-leese
Copy link
Author

I've checked out https://github.com/huiyiqun/json-exporter and have gotten a bit further.

this is the json I am trying to pull metrics in ;

{
"isValid":true,
"validationRuleErrors":[],
"httpStatusCode":200,
"genericErrorMessage":null,
"data":{
"version":"17.8"
}
}

  • job_name: 'XXXX API - PROD'
    metrics_path: /probe
    params:
    jsonpath: [$.data.version] # Look for the version field
    jsonpath: [$.httpStatusCode] # Look for the version field
    static_configs:

I was expecting this to create a new metric label per jsonpath but instead just have a duplicated metric label called "value".

Would like to be able to pre-fix each label with something that is unique;

I.E;
version_value
httpStatusCode_value

Does that make sense?

I am aware that there is a way to rename the metric but cannot see this working in this scenario?

Also - genericErrorMessage generates a "Values could not be parsed to Float64" error message when trying to scrape the value - suspect it is not handling the "null" value.

@SPFZ
Copy link

SPFZ commented Mar 20, 2018

@VR6Pete Can you post the exact response that you get as return? I might be able to assist you in transforming it in the metrics you want.

@pete-leese
Copy link
Author

Hi @SPFZ -

genericErrorMessage

2018/03/20 13:59:00 () could not be parsed to Float64

@SPFZ
Copy link

SPFZ commented Mar 20, 2018

@VR6Pete From what I understand from the code it does not support querying multiple values. This exporter does: https://github.com/kawamuray/prometheus-json-exporter

But you can only read one target and there are 3 open pull request.

If I had the time I would extend one of the exporters to support multiple targets and multi jsonpath' . The only limitation then would be the 2000 character limit for the get request from prometheus to the exporter.

@pete-leese
Copy link
Author

Thanks @SPFZ - I do actually use that exporter for a specific interface I wrote but as you say does not scale beyond that currently.

@pete-leese
Copy link
Author

@SPFZ or anyone else... Willing to put some funds to help push this forward?

Let me know if interested.

@SPFZ
Copy link

SPFZ commented Apr 10, 2018

@VR6Pete As said before I was not happy with any of the json exporters in existance, therefore I wrote an exporter specific to my problem in python.

@pete-leese
Copy link
Author

Is this available on github or are you able to share @SPFZ?

@SPFZ
Copy link

SPFZ commented Apr 12, 2018

It is company internal and specific to our problem, but writing an exporter is simple. A good starting tutorial can be found on Brian Brazils blog: https://www.robustperception.io/writing-json-exporters-in-python/

@pete-leese
Copy link
Author

Thanks for the reply, I just don’t have the time at the moment to learn python I’m afraid.

Still looking for some assistance with getting https://github.com/kawamuray/prometheus-json-exporter upto scratch.

@pete-leese
Copy link
Author

I have another scenario where the string cannot be converted.

json output;

{"version":"18.6.1.12"}

Console output:

2018/08/13 09:00:24 18.6.1.12(string) could not be parsed to Float64

Web UI ouput from probe results;

values is string but cannot be converted to Float64
����� n���t�O�� �����K����Ϥ�.L�MW��DI)c�����A�]�!�|�~S��[L����)�h�wB�}/�QL��F^����#e-"�k=�=9����T���m�B���R'�Z��$�C"��29��,#� ���9�x�-���G���/.���o�.�o�i�>�KN�f����������`ԩ:���

Just to confirm I am running the branched version SPFZ posted earlier on in this discussion.

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

2 participants