你可以使用这个插件:https://github.com/grafana/datasource-plugin-genericdatasource
要使用 2.6 版对其进行配置,请执行以下操作:
将插件的文件放到文件夹中,比如“genericdatasource”。
然后将此文件夹复制到 /public/app/plugins/datasource/。
在directives.js 中将templateUrl 的query.editor.html 更改为:
'public/app/plugins/datasource/genericdatasource/partials/query.editor.html'
还将templateUrl 的query.options.html 更改为:
'public/app/plugins/datasource/genericdatasource/partials/query.options.html'
在plugin.json 中将module 更改为:
'app/plugins/datasource/genericdatasource/datasource',
并将config 更改为:
'public/app/plugins/datasource/genericdatasource/partials/config.html'
然后重启 grafana-server。新数据源现在应该可以在“添加数据源视图”的数据源类型下拉列表中使用。
在此处使用“代理”选项(不是“直接”)以正确处理跨域请求。
您只需要在后端实现 3 个方法:/、搜索、查询。
看这里的例子:
https://gist.github.com/bergquist/bc4aa5baface3cffa109
https://gist.github.com/tral/1fe649455fe2de9fb8fe