grafana / tutorials

A series of tutorials for helping you make the most out of Grafana.
Apache License 2.0
111 stars 29 forks source link

No description of how to access data source options from GOLANG in backend sources #201

Open OptrixAU opened 1 year ago

OptrixAU commented 1 year ago

The documentation clearly shows how to set up the web UI for both the data source configuration and queries, but at no point does it show how to actually access those options in your backend data source.

It's probably quite simple, but since I'm not very familiar with GO I'm more or less bashing my head into the wall.

I can see that in the CheckHealth call they appear to be hidden somewhere in req.PluginContext.DataSourceInstanceSettings.JSONData, but it's then wrapped in a RawJSON object that for some reason won't parse with json.Unmarshal.

Is there a simple example you could provide showing that - if you enter a host name in your data source configuration - you can ACCESS that information in your CheckHealth or Query functions?