How install MQTT plugin in container

Hi,

I try to install MQTT-datasource from GitHub - grafana/mqtt-datasource: MQTT Datasource for Grafana allows streaming data from any MQTT broker running either locally or remotely. in a Docker container. I use Docker Desktop for windows.
I followed the guide to compile the plug-in on windows. But now I don’t know how to install the plugin in the container.
Can anyone help ?

Best regards,
Pat

If using this in a docker/container is anything like using it in a Linux environment, move the compiled plug in to the folder

/var/lib/grafana/plugins

update the /etc/grafana/grafana.ini

# Enter a comma-separated list of plugin identifiers to identify plugins to load even if they are unsigned. Plugins with modified signatures are never loade>
allow_loading_unsigned_plugins = grafana-mqtt-datasource

restart the server, and should work when you try to add data source in Grafana.

1 Like

Hi @antonio79,

Thanks for your answer.

Do you know if I can compile on windows then copy the plugin in the right place or I have to compile on Linux because the container is like-Linux (Official Alpine image) ?

Do you know how copy the folder in the Grafana plugin folder in the container ?

Best regards,
Pat

if for the backend you use the command mage buildAll it will cross build the backend - so when you copy the plugin dist to a different platform it will work - you can use docker cp (docker cp | Docker Documentation) to do the copying - another option would be to just mount the folder to your container - just my 2 cents

3 Likes

Hi @atifshoukatali

I executed mage build all with success.

Regarding the folder mounting in the container, I have the following error message :Error: ✗ Plugin not found (Grafana v8.4.4 linux-amd64).

Here is my docker-compose file :

  grafana:
    image: grafana/grafana:8.4.4
    container_name: grafana-server
    restart: always
    depends_on:
      - influxdb
    environment:
      - GF_SECURITY_ADMIN_USER=yyyyy
      - GF_SECURITY_ADMIN_PASSWORD=yyyyy
      - GF_INSTALL_PLUGINS=grafana-mqtt-datasource
      - GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=grafana-mqtt-datasource
    links:
      - influxdb
    ports:
      - 3000:3000
    volumes:
      - ./grafana-plugins:/var/lib/grafana/plugins
      - grafana_data:/var/lib/grafana    
    networks:
      - influxdb_network 
      
volumes:
  grafana_data: {}
  
networks:
  influxdb_network: 

Do you have an idea why the plugin is not found ?

Best regards,
Pat

dir permissions maybe? :thinking:

1 Like

@atifshoukatali

Do you know or know someone that can help to set permission ?
It’s probably right, because I need to mount a local folder on Windows to container in Linux…

Pat

wait - on a second look - is this a windows host trying to mount on a linux container?
in that case maybe the path is the issue - try to use an absolute path on the src side of the colon

1 Like

@atifshoukatali

I got it !!
I copied the MQTT plugin in the local folder “grafana_plugins” on my Windows host and also mounted the “/var/lib/grafana” on my host

version: "3.8"

services:

  grafana:
    image: grafana/grafana:8.4.4
    container_name: grafana-server
    restart: always
    environment:
      - GF_SECURITY_ADMIN_USER=yyyyy
      - GF_SECURITY_ADMIN_PASSWORD=yyyyy
      - GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=grafana-mqtt-datasource
    ports:
      - 3000:3000
    volumes:
      - ./grafana_plugins:/var/lib/grafana/plugins
      - ./grafana_data:/var/lib/grafana
    networks:
      - grafana_network
      
volumes:
  
networks:
  grafana_network: 

Pat

4 Likes

@patopat I want to kiss you bro. Every single solution says to just add the allow_loading_unsigned_plugins = grafana-mqtt-datasource line and it was good. But I guess none of those solutions were running in a docker container. I had to follow your exact instructions, ie include the environment + the volume, and FINALLY it worked.
Thank you. It was a huge pain in the ass just to build the damn thing. It was driving me crazy to feel like I was so close yet still couldn’t get it to load.

1 Like

Enjoy the MQTT plugin. It’s great!

1 Like