community.grafana
community.grafana copied to clipboard
Draft: Allow datasource to be tested through Grafana after creation
SUMMARY
Introduce post create/update datasource test for Prometheus datasource.
Refs: #220
ISSUE TYPE
- Feature Pull Request
COMPONENT NAME
grafana_datasource.py
Codecov Report
:exclamation: No coverage uploaded for pull request base (
main@8ef798a
). Click here to learn what that means. The diff coverage isn/a
.
@@ 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.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 8ef798a...16c14d4. Read the comment docs.
/rebase
In the documentation for the API in Grafana 9.0.x, there's an endpoint for checking the data source health:
/api/datasources/uid/:uid/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?
- The Prometheus data source looks like this:
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}
- But when requesting to check the health a "Not found" is returned.
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"}
- The Grafana log gives the error "method not implemented" so perhaps this is just not implemented for the Prometheus data source?
ERROR[07-23|08:53:28] Not found logger=context traceID=00000000000000000000000000000000 userId=0 orgId=1 uname= error="method not implemented" remote_addr=172.17.0.1 traceID=00000000000000000000000000000000
@kongslund FYI I have the same result on my side with the health endpoint. It looks worth an issue on the Grafana side