Closed m1kewu closed 11 months ago
Hi @mikewu-tl, It's not necessary to provide a value for the ssl_context
because it's an optional parameter. By default, the functionality uses at the end the default ssl context, but the context is in general helpful, if you are using custom certificates or mTLS.
I didn't find any info from docs I'm afraid.
Thank you for pointing it out. I'll add as a follow up a few sentence to the documentation to make it more clear.
Could you please provide me the used version? I'll setup a test case.
Hi there, the version of this issue is v9.2.1 (34f7baebda)
. Thanks.
Was the code I provided using Bearer API token correct? Please let me know what I can look into to pull the list of folders.
For context, I'm trying to programmatically scrape all dashboards from all folders as json, and import them into a newer Grafana host (9.5+).
Hi @mikewu-tl, are you using the latest version of the grafana-api-sdk
?
Was the code I provided using Bearer API token correct? Please let me know what I can look into to pull the list of folders.
The way you handled it looks too good for me. Could you please describe the way you created the API token/service account? What access rights did you use? My current guess is that the uid is not matched/correctly passed or there is an issue with the token. Do you use a self-signed certificate for the Grafana instances?
The case you just tried should actually work as expected and is being tested here in an integration test.
For context, I'm trying to programmatically scrape all dashboards from all folders as json, and import them into a newer Grafana host (9.5+).
I've got a similar case to back up the dashboards from one system and move it to another Grafana system.
hey @ZPascal thanks for looking into this. After some tinkering I finally found out this:
the Grafana HTTP API and the request
library only supports http/1.1
, which means, for companies that self host Grafana on public cloud (most commonly behind a load balancer) often has http/2
for the endpoint, which is unsupported. In Python, httpx
would be more suitable for this.
In addition, community discussion (https://community.grafana.com/t/export-dashboard-for-external-use-via-http-api/50716) indicates that there is no programmatic way to fetch exportable JSON, but only in UI.
Thanks again for your time in this, I believe we can close this one.
Hi @mikewu-tl
thanks for looking into this. No, problem.
After some tinkering I finally found out this: the Grafana HTTP API and the request library only supports http/1.1, which means, for companies that self host Grafana on public cloud (most commonly behind a load balancer) often has http/2 for the endpoint, which is unsupported. In Python, httpx would be more suitable for this.
Thank you for the update. That explains the case. In general, why should I not support http/2? Feel free to open a feature request!
In addition, community discussion (https://community.grafana.com/t/export-dashboard-for-external-use-via-http-api/50716) indicates that there is no programmatic way to fetch exportable JSON, but only in UI.
I'm currently using the SDK to export dashboards and forward them to another directory inside the same Grafana instance. From my understanding, it should be possible to create the exportable JSON.
I'll close this case and further document the new feature request (HTTP/2 support
) inside this #33 issue.
Hi @mikewu-tl, FYI I've implemented HTTP/2
support for the Grafana API SDK.
Slight change from example:
And the error is:
Do I have to provide a value for
ssl_context
for HTTPS host? What value would that be? I didn't find any info from docs I'm afraid.