Complete guide on setting up Grafana/InfluxDB with Home assistant using official Docker images

Here are the results:

Hello,

I can integrate a lovelace image card (with Grafana export url) and it works but the issue is that I cannot find how to use “zoom” instead to open windows with this image.

I mean that if I try to click on the image from the home page, it open a new tab instead simply open a “popup” like for entities by example…

The creation of a new component is mandatory? :confused:

Best regards,

I have the same problem as in many other posts above, but no solution has been posted so far. Maybe if some of the posters above could have solved the problem by now, can give us their solution.

I am using grafana and a renderer in seperate docker containers. Using the direct image link in the browser works, the renderer is properly called and the rendered panel is shown in the browser.

I am then using this direct link for a camera entity as still image url as proposed:

camera:
  - platform: generic
    name: grafana_panel
    still_image_url: 'http://hostname:3000/render/d-solo/_SoMeID/dashboardname?orgId=1&panelId=8&refresh=10m&from=now-1d&to=now&theme=dark&width=500&height=325'
    username: !secret grafanauser
    password: !secret grafanapw
    verify_ssl: false

I then tried to display this camera entity in lovelace:

      - aspect_ratio: 50%
        entity: camera.grafana_panel
        show_name: false
        show_state: false
        type: picture-entity

In lovelace it will just show this:
pong

The state of the camera entity is idle and it has the following attributes:

access_token: somehextokenthatmusthavebeengeneratedintheprocess
friendly_name: grafana_panel
entity_picture: /api/camera_proxy/camera.grafana_panel?token=sametokeneasabove
supported_features: 0

In the logs of grafana or the renderer are no errors (log level: debug). It seems that the renderer is not even called upon by the picture entity card. No errors in HASS log.

I have not found a solution in the forum. Maybe someone can step forward who knows whats going on and how to fix this.

OK, I have the solution. You may want to use another name or even the IP address in still_image_url: 'http://hostname:3000/. Using the IP address it started to work suddenly.

1 Like

For those that had a lot of issues /w the curl part… I fouind a work around. Throw the curl command into a .sh and then just put your command to sh script.sh if you named it script.sh.

Unfortunately, the image renderer does not work if you are using Grafana in Docker. We need to have it in a separate container. I have not been able to get the curl command working

Hi @arsaboo
I managed to do this. But there was a change in the past few months following a newer version of grafana (can’t remember what)
Check the docker-compose on their github with both the grafana docker and the renderer docker:

This was solved by going into the docker volume I attempted to mount and running “chmod 777 grafana” to open up the grafana folder permissions.

You don’t want everybody to write into the volume. It’s much better to solve it by checking out your user id and adding that one to the docker:

docker run -d -p 3000:3000 --user=1000 --name="grafana"  -v /home/pi/projects/grafana:/var/lib/grafana --restart unless-stopped grafana/grafana

I downloaded the latest docker images (Synology Docker environment). Used the 3000:3000 port and the mapping to /var/lib/grafana. But my container keeps restarting.
I tried adding the PGID and PUID variables but that doesn’t work.
There are 6 other environmental variables starting with GF_PATHS…

What to do?

Heads up for others who may be in the same situation as I was. InfluxDB V2 has been pushed to docker, yet there is no upgrade process in place for docker users (ref)
If your container has automatically updated (watchtower) you’ll start getting these in your HA logs:

InfluxDB database is not accessible due to '401: {"code":"unauthorized","message":"Unauthorized"}'. Please check that the database, username and password are correct and that the specified user has the correct permissions set. Retrying in 60 seconds.

For the time being, adjust your docker compose / docker command to pull tag 1.8.3 or you’ll stop logging data…

5 Likes

Ran into this as well yesterday, I was so confused until I realized that the latest tag now uses v2.

I will write here how I got things done and I feel that the configuration is now rather simple. Thanks @arsaboo for your instructions, those helped me a lot.

  • I Installed Influx and Grafana as docker containers as described above
  • I made the following changes to Grafana to be able to access panels as iframes:
    – enable https access and configured certs
    – enabled anonymous access
    – enabled embedding
  • my docker launch for Grfana is now as follows:
docker run -d \
 -p 3000:3000 \
 --name="grafana" \
 -v /home/ville/grafana:/var/lib/grafana \
 -e GF_SERVER_PROTOCOL=https \
 -e GF_SERVER_CERT_FILE=/var/lib/grafana/certs/fullchain.pem \
	-e GF_SERVER_CERT_KEY=/var/lib/grafana/certs/privkey.pem \
 -e GF_AUTH_ANONYMOUS_ENABLED=true \
 -e GF_SECURITY_ALLOW_EMBEDDING=true \
 grafana/grafana

  • open access to Grafana in your router from outside world
  • select Share for the desired panel in Grafana (not dashboard)
  • select Embed and copy the url
  • create webpage card in Home Assistant and use the copied url. Check that the address is an external address (not local IP).

This configuration did not require image renderer. If you need this, I think the only way currently is to run a dedicated container for it and define the external rendered for Grafana.

Another tip that I struggled long time. For some sensors in Home Assistant the data used decimal commas (in FInland we use comma). Home Assistant treated these as integers, but Influx as text. After I changed the sensor to report numbers using decimal point, things started to work.

1 Like

Wow! I spend few hours to figure out after watchtower upgraded my tickstack yesterday night and my dashboard stopped working saying “No Data” later found more issue and was not able to validate Grafana datasource. And reverted InfluxDB to 1.8.4 and things started working!
Now I noticed this post from you that tell root cause. thanks a lot!

1 Like

Thanks for this, had no idea what had gone wrong! Out of interest, is there a reason you’ve suggested 1.8.3 and not 1.8.4?

I suggested 1.8.3 because 1.8.4 failed for me. If 1.8.4 works for you keep it :wink:

1 Like

So is this not possible with InfluxDB 2.x ? I got HA passing data to Influx, but I can’t for the life of me figure out why Grafana keeps giving me errors.

Looks like there now an upgrade process for docker:
https://docs.influxdata.com/influxdb/v2.0/upgrade/v1-to-v2/docker/

1 Like

Did you upgrade?

yes a while ago. No major issues that I can remember.

Which upgrade procedure did you use?