-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft: Allow datasource to be tested through Grafana after creation #221
base: main
Are you sure you want to change the base?
Conversation
…th basicAuth enabled credentials are admin/admin
…after creation/update The Grafana WUI as a feature on datasource that allows to 'Save & test' the datasource when creating or updating it. This patch allows to run the same query after Prometheus datasource creation and update. A GrafanaHttpError exception was added to improve error management and returned message in case of failure.
Codecov Report
@@ Coverage Diff @@
## main #221 +/- ##
=======================================
Coverage ? 73.25%
=======================================
Files ? 7
Lines ? 729
Branches ? 75
=======================================
Hits ? 534
Misses ? 179
Partials ? 16 Continue to review full report at Codecov.
|
/rebase |
In the documentation for the API in Grafana 9.0.x, there's an endpoint for checking the data source health:
It would be desirable if we could utilize that endpoint in a generic fashion for all current and future data sources. However, I cannot get it to check the health of Prometheus when using Grafana 9.0.4. I'm not sure if I'm overlooking something simple?
Request: export GF_API_KEY=<Grafana API key with Admin role>
curl -H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $GF_API_KEY" \
"http://localhost:3000/api/datasources/uid/U2LhXyg4k" Response: {"id":1,"uid":"U2LhXyg4k","orgId":1,"name":"Prometheus","type":"prometheus","typeLogoUrl":"","access":"proxy","url":"http://host.docker.internal:9090","user":"","database":"","basicAuth":false,"basicAuthUser":"","withCredentials":false,"isDefault":true,"jsonData":{"httpMethod":"POST"},"secureJsonFields":{},"version":2,"readOnly":false}
Request: curl -H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $GF_API_KEY" \
"http://localhost:3000/api/datasources/uid/U2LhXyg4k/health" Response: {"message":"Not found","traceID":"00000000000000000000000000000000"}
|
@kongslund FYI I have the same result on my side with the health endpoint. |
SUMMARY
Introduce post create/update datasource test for Prometheus datasource.
Refs: #220
ISSUE TYPE
COMPONENT NAME
grafana_datasource.py