After hours of searching, I keep getting stuck on the following error:
logger=data-proxy-log userId=1 orgId=1 uname=admin path=/api/datasources/proxy/uid/f321b4d8-3bb1-45b8-9256-60386ec34adf/influx remote_addr=172.19.0.1 referer=“http://localhost:3000/dashboard/new?orgId=1&editPanel=1” t=2023-08-29T11:30:05.9923144Z level=error msg=“Proxy request failed” err=“http: no Host in request URL”
vintecc-capturegrafanaplugin-datasource | logger=context userId=1 orgId=1 uname=admin t=2023-08-29T11:30:05.99235Z level=error msg=“Request Completed” method=GET path=/api/datasources/proxy/uid/f321b4d8-3bb1-45b8-9256-60386ec34adf/influx status=502 remote_addr=172.19.0.1 time_ms=9 duration=9.0361ms size=0 referer=“same_link_as_previous” handler=/api/datasources/proxy/uid/:uid/*
This is how i tried to set up the proxy:
plugin.json:
{
"$schema": "https://raw.githubusercontent.com/grafana/grafana/master/docs/sources/developers/plugins/plugin.schema.json",
"type": "datasource",
"name": "Capture Grafana Plugin",
"id": "vintecc-capturegrafanaplugin-datasource",
"metrics": true,
"backend": true,
"executable": "gpx_capture_grafana_plugin",
"info": {
"description": "Take time series data and use the image provider to get corresponding images",
"author": {
"name": "Vintecc"
},
"keywords": ["datasource"],
"logos": {
"small": "img/logo.svg",
"large": "img/logo.svg"
},
"links": [],
"screenshots": [],
"version": "%VERSION%",
"updated": "%TODAY%"
},
"dependencies": {
"grafanaDependency": ">=9.5.3",
"plugins": []
},
"routes": [
{
"path": "/influx",
"url": "http://localhost:8086/query"
}
]
}
part of my datasource.ts:
doRequest(query: string) {
console.log("to proxy:", `${this.proxyUrl}/influx`);
const observable = getBackendSrv().fetch({
method: "GET",
url: `${this.proxyUrl}/influx`,
params: {
db: this.database,
q: query,
},
});
return new Promise<any>((resolve, reject) => {
observable.subscribe({
next: (response) => {
// console.log("Response:", response);
resolve(response.data); // Resolve the Promise with the response data
},
error: (error) => {
console.error("Error:", error);
reject(error); // Reject the Promise with the error
}
});
});
}
my proxyUrl looks like: to proxy: http://localhost:3000/api/datasources/proxy/uid/f321b4d8-3bb1-45b8-9256-60386ec34adf/influx (this is the output of the console.log)
what am i doing wrong? I hope someone can help me. A BIG thank you in advance!