I am exploring the possibility of creating a backend datasource plugin to interface to an API I am building. I have a client implementation written in go and this appears to be a neat way to proceed. I have been through the documentation (https://grafana.com/docs/grafana/latest/plugins/developing/backend-plugins-guide/) and understand the intention to put more effort into documentation by example, however, the current state of the recommended example appears to be broken (https://github.com/grafana/simple-json-backend-datasource/issues/3). Both the frontend and backend builds do not work out of the box. It is a little concerning that issues have been raised on this example more than 6 months ago and the author nor any other contributor have responded.
I’ve only managed to get the backend building and I’d be more than happy to submit some changes but I sure could do with some pointers on building the frontend component of the simple-json-backend-datasource repo.
Thanks for the pointer @marcusolsson, i’ve yet to compile and test your csv backend data source but it looks like it is exactly what I have been searching for.
I have run into a few issues with the aforementioned example repo. Initially I encountered some build issues which I believe I have overcome. I appear to be able to load the plugin up successfully from grafana (which I am running from within a the official 6.4.5 docker container) I am now faced with a failing data source when I attempt to save and test. It would appear the issue is in the backend but I am unable to get any logs from the backend component of the plugin. stderr appears to be getting swallowed up and not surfaced through the regular logging stream. Any thoughts or pointers on the subject would be greatly appreciated.
Edit: embarrassingly, simply increasing the verbosity of Grafana logging via GF_LOG_LEVEL=debug sees the plugin debug surfaced. This uncovered the fact that data source test function was failing because the backend code is written such that it requires at least 2 fields configured and if not provided the QueryResult is not added to the slice before returning.
Using the approach I listed above you get a DataSourceRequest that contains Queries[] and the time range, and returns a DataSourcResponse (which contains Results[]).
Hi, I’m looking to add a backend plugin to a datasource plugin I’m developing, in order to provide authentication for the datasource. Is the grafana-plugin-sdk-go the way to go for this? Will the zip then contain an executable that grafana will run in isolation on the user machine? Would the backend plugin have access to environment variables on the local machine its running on?
Thank you!
It is not clear to me from these documentation pages were the working Go server code is. I see the Go SDK code but not the code that includes it to run the server.