Working Backend Plugin Example


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 ( and understand the intention to put more effort into documentation by example, however, the current state of the recommended example appears to be broken ( 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 in advance.

1 Like

We’re currently working on a Go SDK for backend plugins, but it’s still in heavy development:

I wrote a sample plugin a while ago, along with some documentation, that might help you in the meantime:

It’s very much in an experimental state, but please submit an issue on the repository if you run into any issues, and I’ll try to update it.


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.

1 Like

Hi @marcusolsson,

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.

1 Like

Oh, yes. Sorry about that :sweat_smile:

I’m glad you got it to work in the end!

Does using “” superceed these?

hclog ""
plugin ""

Using the approach I listed above you get a DataSourceRequest that contains Queries[] and the time range, and returns a DataSourcResponse (which contains Results[]).

Yes. The grafana-plugin-sdk-go is still in early development, but is intended to become the recommended way to build packend plugin.

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!

Have you checked out the documentation for backend plugins?

There’s also a tutorial for how to get started with backend plugins:

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.