Unable to set MQTT broker URI when provisioning MQTT datasource in Docker container

  • What Grafana version and what operating system are you using?

Grafana version v11.0.0, which is run from a custom-build docker container.

  • What are you trying to achieve?

I’m trying to provision a preconfigured grafana-mqtt-datasource using the MQTT datasource plugin.

  • How are you trying to achieve it?

I’ve created the following file /etc/grafana/provisioning/datasources/mqtt-datasource.yaml which is installed inside the Docker container:

apiVersion: 1

datasources:
  - name: 'NES_datatown'
    type: 'grafana-mqtt-datasource'
    uri: 'ws://mosquitto:9001'
    isDefault: true
    editable: true
  • What happened?

The datasource is provisioned, however, the URI field is empty, as in the screenshot below (tcp://localhost:1883 is the default value for an empty field).

Bildschirmfoto 2024-06-14 um 14.25.30

Note that fields like the name, isDefault, and isEditable are correctly picked up.

Curiously, when I use the field name url, the URL is shown in the datasource overview page.

Bildschirmfoto 2024-06-14 um 14.28.44

However, it is not picked up in the configuration.

I tried different capitalizations of uri and url but none work.

  • What did you expect to happen?

The URI field should be prepopulated with the specified value.

  • Can you copy/paste the configuration(s) that you are having problems with?

See above.

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

No

  • Did you follow any online instructions? If so, what is the URL?

i would use this reverse approach. create it manually then see what exactlt are the settings generated by grafana itself

Thank you, this worked! For the record, the correct JSON configuration is this:

datasources:
  - name: 'NES_datatown'
    type: 'grafana-mqtt-datasource'
    isDefault: true
    editable: true
    version: 1
    "jsonData": {
      "uri": "ws://mosquitto:9001"
    }
1 Like