Closed Urhengulas closed 1 year ago
Ha, I just checked how the docker-compose log looks like when I configure it manually and set the URL. And it does look a bit different!
emission-meter-grafana-1 | logger=plugin.meln5674-mongodb-community t=2023-10-20T09:50:33.780475076Z level=info msg="CheckHealth called" request="map[Headers:map[http_X-Datasource-Uid:PD3083DE512941242 http_X-Grafana-Org-Id:1] PluginContext:map[AppInstanceSettings:
DataSourceInstanceSettings:map[BasicAuthEnabled:false BasicAuthUser: Database: DecryptedSecureJSONData: ID:1 JSONData:map[url:mongodb://mongo_db:27017] Name:mongodb-community Type:meln5674-mongodb-community UID:PD3083DE512941242 URL:mongodb://mongo_db:27017 Updated:2023-10-20T09:50:33Z User:] OrgID:1 PluginID:meln5674-mongodb-community User:map[Email:admin@localhost Login:admin Name: Role:Admin]]]"
Above the log contained JSONData:map[]
, now it contains JSONData:map[url:mongodb://mongo_db:27017]
. So I guess your plugin does not use the URL paramter, but a separate one?!
Following provisioning configuration works!!
apiVersion: 1
datasources:
- name: mongodb-community
type: meln5674-mongodb-community
access: proxy
# url: "mongodb://mongo_db:27017"
isDefault: true
editable: true
jsonData:
url: "mongodb://mongo_db:27017"
My problem is therefore solved 😁
On a sidenote: Maybe it makes sense for you to switch to the top-level url
parameter? I don't know if there is any advantage, but it seems like the default way to go.
Hi @meln5674, thank you for the great plugin!
I am using it with docker-compose as you have it in the examples. Now I want to provision the datasource definition so I do not have to configure it manually when I setup the service. Provisioning works by passing grafana a yaml file with the parameters of the datasource. Docs are here: https://grafana.com/docs/grafana/latest/administration/provisioning/.
Unfortunately I cannot get it to work completely. It does register the datasource, but I get a parsing error.
Setup
You can find my code at https://github.com/Urhengulas/emission-meter/tree/4a74cf9a89ae6d9174d0e8adf2f52ebe9ca7270a.
Initially I configured the datasource manually in the UI by setting the URL to
mongodb://mongo_db:27017
. This works and I am able to connect to and query the database.Now I am configuring the datasource like this:
and pass the file to the container through a volume:
It successfully registers the datasource and shows up like that:
(Note the
mongodb://mongo_db:27017
)Error
When I click on the datasource and click "Save & test" I get following error in the UI:
In the docker-compose logs I get following two log lines:
While it says "Request Completed", which sounds rather positive, the status code is
400
.How to make it work? 😁