This is just an update of my previous post of how to use MMM-Grafana-Chart and MMM-Grafana-gauge in your magic mirror. I wanted to post this as I have been struggling myself to get this working. There are two things that you might run into.
- The background might be gray instead of black
This could be fixed before Grafana 5 by changing the CSS. However this is not really possible now as you will have to rebuild
- If running Grafana in Docker there are issues when setting the permissions.
The setting will also be lost when recreating and pulling the latest image. You will also run into problems in the container as teher is no nano or vi.
But we will take this from start. You will end up with a working Grafana Gauge panel with black background on your Magic Mirror.
Start by installing the MMM-GrafanaGauges
cd ~/MagicMirror/modules git clone https://github.com/SvenSommer/MMM-GrafanaGauges
I will not install MMM-GrafanaCharts as there will be no good way to get the background all black. You will see this later.
{ module: 'MMM-GrafanaGauges', position: 'top_left', // This can be any of the regions. header: 'Test Graph', config: { host: "192.168.0.1111", //Mandatory. See url when displaying within grafana port: 3000, // Mandatory. dashboardname: "sun", // Mandatory. orgId: 2, // Mandatory. showIDs: [5],// Mandatory. PanelId from the url. width: "100%", // Optional. Default: 100% height: "100%", // Optional. Default: 100% refreshInterval: 900 //Optional. Default: 900 = 1/4 hour } },
Edit your configuration file like above. Make sure you use a dashboardname that will be created soon.
Now tonnect via ssh to your dockerhost running Grafana. In there type:
sudo docker exec -u root -it grafana bash
This will open a root prompt in the container. Will should now edite the grafana.ini. However this will not be possible as there is no editor installed. Install nano by typing:
apt-get install nano -y
apt-get update
You may have to run update if the nano install fails.
Usually you want to keep the container as small as possible and this is the reason there is no editor installed. Edit /etc/grafana/grafana.ini. I know you may think that your grafana.ini file is within your local path of your docker container. In my case /srv/docker/grafana/ and the file is there but changing this here wont affect Grafana. When you change the file you will enable annonymous access for the orgname magic mirror. We will create that. You may not want to enable this for your main org.
#################################### Anonymous Auth ###################### [auth.anonymous] #enable anonymous access enabled = true # specify organization name that should be used for unauthenticated users org_name = magicmirror # specify role for unauthenticated users org_role = Viewer
Open Grafana and add an new org. Name this the same as you wrote in the config.
Now create your gauge.The secret is to set the thresholds colors to all black. Use any other setting you want. Now also chech the url:
https://mygrafanahost/d/V12csvwiz/sun?tab=visualization&orgId=2&fullscreen&edit&panelId=5
The important stuff is the org id and the panel id. This should be in the module config as above.
If you have done everything correct now you will see the info on your mirror without any username and with black background. I have used this with Grafana 6.