You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
after I have found out the issue with the JSONpath expression #343 I managed to get JSON data in Grafana. So far so good but sometimes the graphs was broken and after checking the root cause I found out the Web API of our photovoltaic management console is generating the JSON data not in a consistent way.
This means, the arrays are not on the same location on every GET request. For example, one time it is like...
Unfortunately, by design or fault, if there is no current from the PV, the element "value" is not in the array. Here I could use the JSONata expression to fill '0' if the element is missing.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi all,
after I have found out the issue with the JSONpath expression #343 I managed to get JSON data in Grafana. So far so good but sometimes the graphs was broken and after checking the root cause I found out the Web API of our photovoltaic management console is generating the JSON data not in a consistent way.
This means, the arrays are not on the same location on every GET request. For example, one time it is like...
{ "powerDetails": { "timeUnit": "QUARTER_OF_AN_HOUR", "unit": "W", "meters": [ { "type": "Purchased", "values": .....
And one minute later it is like:
{ "powerDetails": { "timeUnit": "QUARTER_OF_AN_HOUR", "unit": "W", "meters": [ { "type": "Consumed", "values": .....
So to fetch the right field into Grafana I used expressions like:
$.powerDetails.meters[?(@.type == "Purchased")].values[*].value
Unfortunately, by design or fault, if there is no current from the PV, the element "value" is not in the array. Here I could use the JSONata expression to fill '0' if the element is missing.
($exists($.powerDetails.meters[3].values[*]."value") ? $.powerDetails.meters[3].values[*]."value" : 0)
This only works if the array '[3]' is actually the current element (here it is named "Production").
How to add/change the JSONata expression to add the 'type' condition?
Beta Was this translation helpful? Give feedback.
All reactions