cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Helping my plugin understand nested json... keys?

Brynatrace
Observer

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!

2 REPLIES 2

Mike_L
Dynatrace Guru
Dynatrace Guru

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)

Mike

Brynatrace
Observer

That worked, thanks muchly!

Featured Posts