Trying to setup influxdb and grafana

I compiled grafana myself. I wasn’t easy.

This worked ok to get phantomjs.

This to compile grafana:
http://gridengine.eu/index.php/other-stories/230-installing-grafana-on-raspberry-pi-2-2015-10-24

But I could not make the package, because they’ve changed the name of phantomjs. I had phantomjs, and the script wanted phantojs-prebuild. I got it working by removing phantomjs from grafanas package.json. It’s not pretty but is works. I have phantomjs on my path.

Edit:I have Pi3

This is for a previous release of phantomjs and unfortunately, build that way, the resulting binary has more dependency that it should and you won’t have the possibility to move it to an other distro has easily as you should. If you are interested, you can see the way they build the last version, v2.1.1, (see deploy/ on the v2.1.1 tag).
Recent versions (I think >=v3) of grafana will need a v2.1.1 binary to build cleanly.
The change in naming, is not for phantomjs binary but for the npm module that deploys phantomjs binary. It was named phantomjs in the beginning but since this was confusing, they changed the name to phantomjs-prebuild. In fact, this is the recent version of this module that will require a v2.1.1 phantomjs binary.

There are cleaner way to build grafana and deb packages can be build to with not so much trouble I you need them. If you are interested, you can read detailed steps on how to do it here. Alternately, you can simply use this .deb this PuckStar tested it on Pi3 and reported it is working fine.

Im trying to get influx and grafan running on my pi3 with hass.
Do you run influx and grafana on the same rpi3 with hass?
How many entitys do you have and how large has your influxdb get and for how many days have you run it?
I have 100 entitys and my home_assistant_v2.db is 200mb after only 1v i think I have to by a largert ssd card :frowning:

Would you please summarize the steps you took to install this, it would help alot :slight_smile:

Yes I run it on the same pi3 with HASS.
About how large it gets I’m trying to find that out myself as well :slight_smile:
I found this info but am not sure what is means:
http://imageshack.com/i/pnWMrohUp

note that your home_assistant.db is not the Influx db and that you can put a retention on that as well:
put this in your hass config:

recorder:
  purge_days: 30

I followed the steps in the blog https://home-assistant.io/blog/2015/12/07/influxdb-and-grafana/ except the installation of influx itself. See other replies in this topic of how I managed with that (like using this wget: wget https://github.com/fg2it/grafana-on-raspberry/releases/download/v3.1.1-jessie/grafana_3.1.1-1470786449_armhf.deb4).

I have my recorder set to 30 days. But would be nice to have some temperature readings stored longer.

I’m trying to find something other than InfluxDB & Grafana.

Con’s for InfluxDB:

  • updating old data is difficult. That is understandable because it’s meant to be time-series insert-only database. The problem is and will be that HA device names may change and I as user cannot do anything about it. Then if you have years worth of data, it can suddenly change and you have to insert the old data again. It is obvious it is not working.
  • Influxdb does not support joins anymore, so you cannot join data. Only one table at one query. You cannot create another mapping table from preventing the device name change problem. You cannot actually do anything because the lack of complex multi-table queries.
  • no functions yet to take advantage of time series data, meaning fetch data of previous and next rows.

Pro’s

  • its easy to use Grafana graphs.
  • easy on SD card.

For Grafana you can now do:
sudo apt-get install adduser libfontconfig curl -L https://github.com/fg2it/grafana-on-raspberry/releases/download/v4.0.1/grafana_4.0.1-1480722482_armhf.deb -o /tmp/grafana_4.0.1-1480722482_armhf.deb sudo dpkg -i /tmp/grafana_4.0.1-1480722482_armhf.deb
sudo systemctl daemon-reload
sudo enable grafana-server
sudo start grafana-server

Maybe someone in here can help me too. I’m not having any luck on installing influxdb on hass aio.

From console while trying to install:

pi@raspberrypi:~ $ curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add - source /etc/os-release
OK
pi@raspberrypi:~ $ test $VERSION_ID = "7" && echo "deb https://repos.influxdata.com/devian wheezy stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
-bash: test: =: unary operator expected
pi@raspberrypi:~ $ test $VERSION_ID = "8" && echo "deb https://repos.influxdata.com/devian jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
-bash: test: =: unary operator expected
pi@raspberrypi:~ $ sudo apt-get update && sudo apt-get install influxdb         Hit http://repo.mosquitto.org jessie InRelease
Hit http://mirrordirector.raspbian.org jessie InRelease
Hit http://archive.raspberrypi.org jessie InRelease
Hit http://repo.mosquitto.org jessie/main armhf Packages
Hit http://mirrordirector.raspbian.org jessie/main armhf Packages
Hit http://mirrordirector.raspbian.org jessie/contrib armhf Packages
Hit http://mirrordirector.raspbian.org jessie/non-free armhf Packages
Hit http://mirrordirector.raspbian.org jessie/rpi armhf Packages
Hit http://archive.raspberrypi.org jessie/main armhf Packages
Hit http://archive.raspberrypi.org jessie/ui armhf Packages
Ign http://repo.mosquitto.org jessie/main Translation-en_GB
Ign http://repo.mosquitto.org jessie/main Translation-en
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en
Ign http://mirrordirector.raspbian.org jessie/main Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/main Translation-en
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en_GB
Ign http://archive.raspberrypi.org jessie/main Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en
Ign http://archive.raspberrypi.org jessie/main Translation-en
Ign http://archive.raspberrypi.org jessie/ui Translation-en_GB
Ign http://archive.raspberrypi.org jessie/ui Translation-en
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package influxdb
pi@raspberrypi:~ $ sudo service influxdb start
Failed to start influxdb.service: Unit influxdb.service failed to load: No such file or directory.

You’ve got a couple of typing errors.

It seems two different commands got accidentally merged in the first line.

Should be like this:

curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add - 

source /etc/os-release

The second problem is that you have devian where it should say debian in the second and third command you have there.

I wrote a walkthrough on influxdb/grafana integration here in case it helps later:

Ha! How embarrassing… Thank you.

For anyone who comes across this thread via Google - I have published a fairly detailed guide about how to set up Grafana and InfluxDB on a Raspberry Pi with HA installed on my blog. The guide is in Swedish, sadly, but Google Translate should work well.
https://snillevilla.se/snygg-statistik-i-home-assistant-med-grafana-och-influxdb/

3 Likes

Very nice guide :smiley:

Thanks for this guide!

A live saver!!! Thanks a lot!

Now i see that influx recorded the data after installing all the stuff. I would like to see the older data in grafana too. How do i do that?

O, and by installing this way by @snillevilla, do i now have two databases? One from Hass and one from influxdb?

EDIT:

Ok i got it:

$ sudo su -s /bin/bash homeassistant
$ source /srv/homeassistant/bin/activate
$ hass --script influxdb_import --dbname INFLUXDB_DB_NAME

How did you get the Charts entry in your menu ?

Second question : I installed succesfully InfluxDB & Grafana from add-on repository. It works fine on local network, but Grafana failed to access to Influxdb when I’m trying to access from ouside my local network (I can access to Grafana webpage and HASS webpage from ouside). Any clue ?

For your 1st question see here: https://home-assistant.io/components/panel_iframe/

You can achieve this with panel_iframe… ex:

panel_iframe:
  grafana:
    title: 'Charts'
    icon: mdi:elevation-rise
    url: 'http://192.168.129.115:3000/dashboard/db/energy'

I use a vpn for connecting to local network at home so i don’t have that problem. It’s like sitting at home while at work :wink:

Arghhhhh Can’t have iframe panel if using SSL connection… I understand now why you’re using VPN :slight_smile:

I think you can use iframe but you also need to expose your grafana via SSL since a ssl/tls protected page cannot iframe a non SSL/tls page.
If you have a reverse proxy (nginx, caddy etc) then set up as different subdomain etc.

I’m trying to do it but it’s not really working. Anyway, you can change environment variables of the grafana server using some options when launching the addon. For example, I’m using caddy proxy and the Infludb and Grafana addon, so, in the option you can write:

{
  "env_var": [
    {
      "name": "GF_AUTH_ANONYMOUS_ENABLED",
      "value": "true"
    },
    {
      "name": "GF_SERVER_PROTOCOL",
      "value": "https"
    },
    {
      "name": "GF_SERVER_DOMAIN",
      "value": "xxxx.duckdns.org"
    },
    {
      "name": "GF_SERVER_CERT_FILE",
      "value": "/ssl/caddy/acme/acme-v01.api.letsencrypt.org/sites/xxxx.duckdns.org/xxxx.duckdns.org.crt"
    },
    {
      "name": "GF_SERVER_CERT_KEY",
      "value": "/ssl/caddy/acme/acme-v01.api.letsencrypt.org/sites/xxxx.duckdns.org/xxxx.duckdns.org.key"
    }
  ]
}

I’m sure the that the grafana addon will use these variables, but something is missing because it says:
t=2017-11-17T15:49:20+0100 lvl=eror msg=“Fail to start server” logger=server error=“open /ssl/caddy/acme/acme-v01.api.letsencrypt.org/sites/xxxx.duckdns.org/xxxx.duckdns.org.crt: permission denied”