Grafana 7.x Data source Route Problems

Hi,

I’m developing a plugin so our users can use our API as Data Source in Grafana. I’ve used the new Grafana toolkit to generate the plugin, but I ran into quite the big problem: it seems as if the routes in plugin.json are not being picked up. The return value is in every case 200 OK but instead of the actual call being proxied to our API, it just returns the Grafana Datasource config page.
Am I doing something wrong or is there something I’m missing?

The config is as follows:

"routes": [
   {
      "path": "connection-test",
      "method": "*",
      "url": "{{.JsonData.baseUrl}}/v1/environments",
      "headers": [
        { "name": "Api-Key", "content": "{{.SecureJsonData.apiKey}}" }
      ]
   }
],

The connectionTest function of the data source does the following request:

const options: BackendSrvRequest = {
  url: '/connection-test',
  method: 'GET',
};

return this.backendSrv.datasourceRequest(options);

I’ve also tried to call get()/post() directly, rather than datasourceRequest() but to no avail. I also tried to include backendSrv using getBackendSrv() instead of injecting it in the constructor, which also did not produce any different results… I’ve also tried to make the calls using the proxy api endpoint, as can be seen in the kentik-app plugin, which also didn’t change the results.

I’m quite at a loss here… If I can’t get this running, I will have to change the API Key to a non encrypted field and make the request directly, rather than using the proxy.
The complete project can be found in our GitHub repo.

Cheers,
David

I since have proceeded with the implementation using the non-encrypted API Key. However the version with the mentioned approach is still available in a separate branch

Cheers