Backend Datasource Plugins and passing data from ConfigEditor

Hi,

Some background;

For Grafana V6.7, I wrote a datasource plugin for Db2 for z/OS. Because Db2 for z/OS does not natively support REST in the way that Grafana would like it, I had to write an intermediate node.js server that would make the necessary translations and just call Db2 through more conventional channels. From a survey among colleagues from other local (Belgium) companies, there seemed to be quite a bit of interest (most people never see their Db2 data visualized in the way Grafana can).

With Grafana V7.x, backend datasource plugins have been introduced. This could forego the need to run the aformentioned node.js server, which I would like very much. For the previous project I had to learn javascript, Angular, and node.js. For V7.x, I’m now learning React and Go, with varying degrees of succes.

_

My question is the following; how is the backend Go module supposed to access the config settings that have been made in the ConfigEditor frontend? In the SampleDataSource example I can see that the DataSourceInstanceSettings is being passed to newDataSourceInstance, which in turn disappears as a parameter in datasource.NewInstanceManager, which returns an InstanceManager, which doesn’t contain any of the stuff in DataSourceInstanceSettings. The documentation mentions that I should be using the InstanceManager, though I can’t quite figure out just what I’m supposed to be doing with it (it’s not used after creation in the SampleDataSource example).

I tried diving in to the Grafana and plugin sdk source, but I’m about 5 layers deep and quickly losing track.

I can tell that DataSourceInstanceSettings contains fields that correspond to the basic stuff you expect a datasource to need (url, user, database, etc). Do I have to implement my own version of DataSourceInstanceSettings if I want to add additional fields? Or am I supposed to throw those into the JSON field of DataSourceInstanceSettings?

I’m not sure if the tutorials/samples/documentation for backend datasource plugins are still under construction, but for those starting way back such as myself, some more verbose examples could certainly help. Although me not being able to figure it out may indicate that I need more experience before tackling backend datasource plugins in V7.x.

Kind regards,
Jan

To anyone looking for some good examples on how to implement a backend datasource plugin, I used https://github.com/rockset/rockset-grafana-backend and https://github.com/scylladb/scylla-grafana-datasource.

Perseverance is key, my Db2 for z/OS plugin will be released soon after some more polishing.

-Jan