【发布时间】:2021-11-12 10:34:09
【问题描述】:
我正在尝试按照示例从 Grafana 开发数据源插件。最终我希望我的插件使用 Oauth,但即使只有基本的 Grafana 数据源代理示例,我似乎也遇到了问题。 我已经更新了我的 plugin.json、类和构造函数。
我已经设置了这个硬编码示例。
在 plugin.json 中
{
"path": "grafana",
"url": "https://github.com"
}
],
还有一个示例 testDataSource()
async testDatasource() {
return getBackendSrv()
.datasourceRequest({
url: this.url + '/grafana/grafana',
method: 'GET',
})
.then(response => {
if (response.status === 200) {
return { status: 'success', message: 'Data source is working', title: 'Success' };
} else {
return { status: 'failure', message: 'Data source is not working: ' + response.status, title: 'Failure' };
}
});
}
当我尝试保存/测试此数据源以调用该方法时,我在前端 HTTP 错误 网关错误 在日志中
t=2021-09-17T14:31:22+0000 lvl=eror msg="数据代理错误" logger=data-proxy-log userId=1 orgId=1 uname=admin path=/api/datasources/proxy /9/grafana/grafana remote_addr=172.17.0.1 referer=http://localhost:3000/datasources/edit/9/error="http: proxy error: http: no Host in request URL"
我本来希望将请求路由到数据源代理并为此向 github 发出请求,但似乎 Grafana 正在向 /api/datasources/proxy/9/grafana/grafana 发出请求,但什么都没有捡起来?
【问题讨论】:
标签: authentication plugins proxy datasource grafana