29 Apr 2021 02:29 PM - last edited on 12 May 2021 02:58 PM by laima_vainina
Hi folks,
I'm trying to get a plugin to understand some json that's formatted a bit differently than I have found in the demo files, and my best guesses are still causing an error:
Error: value must be convertable to float, got <class 'dict'> instead
It's difficult for me to figure out if it's the metric that's upset, or the results_builder, etc. - has anyone set up something with this sort of nested json before:
My JSONreturns:
"exampleCount": {
"success": 6754,
"error": 348
},
And my best guesses have been:
myplugin.py:
self.results_builder.absolute(key="exampleCount", value=stats['exampleCount'], dimensions={'success': 'error'}, entity_id=pgi_id)
plugin.json:
{
"timeseries": {
"key": "exampleCount",
"unit": "Count",
"displayname": "Example Count",
"dimensions": [
"success",
"error"
]
}
thanks all!
Solved! Go to Solution.
29 Apr 2021 03:20 PM
Hi,
Change the plugin.json to say:
"dimensions": [
"status"
]
And in myplugin.py:
self.results_builder.absolute(key="exampleCount", value=stats['exampleCount']['success'], dimensions={'status': 'success'}, entity_id=pgi_id)
self.results_builder.absolute(key="exampleCount", value=stats['exampleCount']['error'], dimensions={'status': 'error'}, entity_id=pgi_id)
29 Apr 2021 04:02 PM
That worked, thanks muchly!