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

metrics with 0 value ( also false ) are mapped to NaN #25

Closed
abenbouz opened this issue Dec 7, 2020 · 16 comments
Closed

metrics with 0 value ( also false ) are mapped to NaN #25

abenbouz opened this issue Dec 7, 2020 · 16 comments
Labels
type/bug Unexpected behavior or a feature is broken

Comments

@abenbouz
Copy link

abenbouz commented Dec 7, 2020

hello Marc ,

can you please help resolving the floowing issue :
metrics with 0 value ( also false ) are mapped to NaN
ENV :

  • Grafana version 7.3.4
  • grafana-json-datasource version 0.7

FYI : mapping is working well with previous version ( 0.6.4 )

Regards

@marcusolsson
Copy link
Contributor

Thank you for reporting this! I'll look into it 👍

@marcusolsson marcusolsson added the type/bug Unexpected behavior or a feature is broken label Dec 7, 2020
@abenbouz
Copy link
Author

abenbouz commented Dec 7, 2020

thanks for you prompt action
i forget to mention that i'm using Table plugin

@marcusolsson
Copy link
Contributor

Could you paste the JSON and the query you are using, so that I reproduce this?

@abenbouz
Copy link
Author

abenbouz commented Dec 7, 2020

i'm using a private backend so you don't have acess to it
but will give you some outputs 👍

Path : /client Query string : type=X&attributes=*

$.client[?(@.name=='$name')].name
$.client[?(@.name=='$name')].status.child

{
"request": {
"url": "api/datasources/proxy/9/client?type=X&attributes=*",
"method": "GET",
"hideFromInspector": false
},
"response": {
"client": [
{
"name": "XXXXX",
"status": {
"child": 0
},
"type": "X"
}
]
}
}

anyway you can reproduce it using any data with 0 as a value

@marcusolsson
Copy link
Contributor

I tried with this JSON:

[
  {"number": 0, "boolean": false},
  {"number": 2, "boolean": true}
]

which seems to work

Screen Shot 2020-12-07 at 16 26 20

@marcusolsson
Copy link
Contributor

marcusolsson commented Dec 7, 2020

I can reproduce it with your example. I think the error occurs when there's only one item in the array.

@abenbouz
Copy link
Author

abenbouz commented Dec 7, 2020

i don't think it related to the number of items

@abenbouz
Copy link
Author

abenbouz commented Dec 7, 2020

since i have the same behaviour with a lot of items

@marcusolsson
Copy link
Contributor

Yeah, you're right.

Zeros:

  • [0, 0, 0] becomes [NaN, NaN, NaN]
  • [0, 0, 1] becomes [0, 0, 1]

Booleans:

  • [false, false, false] becomes [NaN, NaN, NaN]
  • [false, false, true] becomes [false, false, true]

Looks like it fails when all values are "falsy".

@abenbouz
Copy link
Author

abenbouz commented Dec 7, 2020

in fact in depends on the selct Json Path
if you select just one item based on some creteria you have the problem

@abenbouz
Copy link
Author

abenbouz commented Dec 7, 2020

and if you do not choose any filter like (?(@.name=='$name') it should be ok

@abenbouz
Copy link
Author

abenbouz commented Dec 7, 2020

and please note that it was working fine in previous version

@marcusolsson
Copy link
Contributor

I've found the issue, and working on a fix.

@abenbouz
Copy link
Author

abenbouz commented Dec 7, 2020

perfect thanks

@marcusolsson
Copy link
Contributor

Fixed in v0.7.1. Let me know if you're still having issues!

@abenbouz
Copy link
Author

abenbouz commented Dec 7, 2020

i apreciate well your reactivity :)
V0.7.1 is working like a charm
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Unexpected behavior or a feature is broken
Projects
None yet
Development

No branches or pull requests

2 participants