Home Assistant collects volumes of (time series) data that are well suited for some fancy graphs. Although the History component provides some nice plots, I am sure you have always wanted those fancy Grafana plots. The problem, however, is that low-powered device such as Raspberry Pi that most of us use for our Home Assistant setup are not well suited for such operation.
Instead of running InfluxDB and Grafana on a Raspberry Pi or a different system and go through the classic approach of installing both tools separately, you can run them in a Docker container on another machine. For this tutorial, I am using a Synology NAS, but the instructions should apply to other devices that can run Docker. Just follow the steps below:
SSH into your NAS. You may have to run sudo su if you are getting permission errors.
Download the docker-statsd-influxdb-grafana image using the command:
docker pull samuelebistoletti/docker-statsd-influxdb-grafana
The image should now be running and both InfluxBD and Grafana should be now up and running.
You can access InfluxDB at http://NAS_IP_ADDRESS:3004/ and Grafana at http://NAS_IP_ADDRESS:3003/
Navigate to http://NAS_IP_ADDRESS:3004/ and create the database home_assistant using the command CREATE DATABASE home_assistant.
![](upload://ei0nI97loIS3LJQdaAWxW0mIN7U.png)
Now, you need to configure Home Assistant to use InfluxDB. Since, we did not add any username/password to our database, we can simply add the following to our configuration.yaml (replace the IP address with that of the device running Docker) and restart Home Assistant to setup InfluxDB (you will have to fine tune it based on your preferences):
influxdb:
host: 192.168.2.113
Next, we need to configure Grafana to use InfluxDB. Navigate to http://NAS_IP_ADDRESS:3003/ to access Grafana (login with username and password root) and add your first data source. Here’s how you can configure Grafana to use InfluxDB database. Note that 192.168.2.113 is the IP address of my NAS.
![](upload://3baq8j1cq85yPa4nQ6niP7M3LOs.png)
You should see Data source is working if you have configured everything correctly.
With all that configured, you are now ready for the fun stuff. You can create as many dashboards as you want and then import the same in Home Assistant.
To add the Grafana dashboard in HA, use the following config:
Thanks for this guide but I’m stuck at step 8. There’s no option for me to edit data sources. I’m currently running MySQL for the back-end under the database name ‘homeassistant’ and I suspect that might be the culprit. I can’t figure out how to re-create schema as ‘home_assistant’ in InfluxDB because the InfluxDB UI doesn’t let me create tables. And I can’t figure out how to run the db migration script discussed in the component configuration because I can’t run ‘hass’ from the command line (command not found and grep-ing for ‘hass’ doesn’t turn up anything useful).
FYI – Trying to get Grafana “Latest” (6.4.x) in Docker is failing with “No such file or directory.”
I was able to get back up specifying an older build (image: grafana/grafana:6.3.6)
Known issue…It will likely be fixed before you find this thread…but it sure bothered me for a while. You can track the issue here:
Docker: ARM images doesn’t work since v6.4.x #19585
Thank you @dixkom
we should update the article above. I almost was going to try with another docker image because the influxdb port wasnt working anymore.
I use this approach with the Grafana addon, but if I don’t visit the Grafana UI for a while I get a 401 error on all my embedded graphs. Is there any way to prevent this from happening?
hi, was able to setup this docker also with latest instructions from the author in his github, only thing I don’t know where to find grafana.ini to set auth enable in rder to have iframe working in HA, can someone explain me how to find grafana.ini file inside the docker or create a new one and make it working? Thank you.
My HA is running in a virtual machine within unRaid.
I followed this guide, well more or less: I could not get the InfluxDB docker on my unRaid to start up, so using the InfluxDB addon in HA and Grafana in unRaid and everything is connected and I am able to access Home Assistant and Glances DB I created on Influx in HA.
I created dashboards in Grafana and changed the GF_SECURITY_ALLOW_EMBEDDING=true,
Here is my docker compse for Grafana;
added an iframe to lovelace but get the below error:
**If you're seeing this Grafana has failed to load its application files**
1. This could be caused by your reverse proxy settings.
2. If you host grafana under subpath make sure your grafana.ini root_url setting includes subpath. If not using a reverse proxy make sure to set serve_from_sub_path to true.
3. If you have a local dev build make sure you build frontend using: yarn start, yarn start:hot, or yarn build
4. Sometimes restarting grafana-server can help
Some googling and looking at Grafana config documentation tells me that it is something to do with my grafana server settings, below. But i’m not sure what to change.
It was a little while ago, but pretty sure I had the same problem until I sorted out the reverse proxy (nginx). I’m running HA in a docker, and am using the linuxserver/swag container (previously called linuxserver/letsencrypt) for duckdns/reverse proxy/etc so my nginx directory structure maybe different from yours, but for me I edited the file letsencrypt/nginx/site-confs/default and added this:
### Grafana
server {
listen 443 ssl;
root /config/www;
index index.html index.htm index.php;
server_name grafana.yourduckdnshostname.duckdns.org;
include /config/nginx/ssl.conf;
client_max_body_size 0;
location / {
include /config/nginx/proxy.conf;
proxy_pass http://192.168.1.9:3000;
}
}
The missing part of the puzzle for me is being able to view the panel iframes in HA over https.
Currently these are not visible to remote connections, including the HA companion app.
Only visible locally.
My limited understanding is that this is because the Grafana URLs are http, rather than https.
Achieving this is currently beyond me, but if anyone can provide guidance it would be appreciated. In the meantime I continue to research a possible solution for my Docker installation.
Somehow my password changed ( for the second time). Anyone who can help me ?
I logged in with putty to root and then used this code : docker exec -ti <container_name> grafana-cli admin reset-admin-password mypass@123 . I get the message that my admin pass is changed, but I cant log in with it …
Unable to login to grafana using admin/admin in the point 8. I found on github that people were dealing with this problem but without solution working for me. Any ideas? Thanks
ok, so I finally installed addon grafana and connected to the influxdb in the docker on my Synology NAS. What is actually the benefit of running grafana in Docker (when its filled with these bugs not letting you even reset admin password using grafana cli)? I guess all data will be in the influxdb, so my backups will again be below 1MB instead of 1.5GB
Hi guys, i also did setup a big while ago influxDB and grafana on my proxmox, however it still works great, but here is the thing i don’t even understand anymore…
So before my real life accident i did set this all up, after losing memory for some time and still recovering i’m trying to find out how influxDB is getting the data from home assistant…
As in Home Assistant is no addon even installed, and in InfluxDb the only thing i use is a bucket, but i can’t find out how it receives the realtime data…
I did check everything, i can not find it out…
It still gets the data every 5 seconds from my Home Assistant server in the bucket of InfluxDB… and i can read the data in Grafana…
In grafana the server url from influxDB is the one using the bucket, and nothing else…