InfluxDB+Grafana persistence and graphing

Hey all. Ive tried everything and i just cant get this to work.

I cant start influx ssh, i get failed to connect to host.
ensure the service is running.

[19:03:50] openhabian@openHABianPi:/lib/systemd/system$ sudo systemctl start influxdb
[19:04:19] openhabian@openHABianPi:/lib/systemd/system$ influx
Failed to connect to http://localhost:8086
Please check your connection settings and ensure 'influxd' is running.
[19:04:45] openhabian@openHABianPi:/lib/systemd/system$ sudo systemctl start influxd
[19:04:53] openhabian@openHABianPi:/lib/systemd/system$ influx
Failed to connect to http://localhost:8086
Please check your connection settings and ensure 'influxd' is running.
[19:04:56] openhabian@openHABianPi:/lib/systemd/system$ influx d
Failed to connect to http://localhost:8086
Please check your connection settings and ensure 'influxd' is running.

I have installed using the openhabian-config. Grafana is installed. I just cant get this to work
I cant even figure out where to start.

after purging influx db and trying to reinstall i get this

Fetched 46.6 MB in 7s (6,376 kB/s)
Selecting previously unselected package influxdb.
(Reading database ... 48677 files and directories currently installed.)
Preparing to unpack .../influxdb_1.7.7-1_armhf.deb ...
Unpacking influxdb (1.7.7-1) ...
dpkg: error processing archive /var/cache/apt/archives/influxdb_1.7.7-1_armhf.deb (--unpack):
 trying to overwrite '/usr/bin/influx', which is also in package influxdb-client 1.0.2+dfsg1-1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/influxdb_1.7.7-1_armhf.deb
Updating FireMotD available updates count ... 2019-07-03 19:12:04,142: FireMotD: Error: Template folder doesn't exist. Upgrading from an older version? Please run make again or run the install function "FireMotD -I -v".

E: Sub-process /usr/bin/dpkg returned an error code (1)

$ systemctl daemon-reload

$ systemctl enable influxdb.service
Failed to enable unit: File influxdb.service: No such file or directory

$ systemctl restart influxdb.service
Failed to restart influxdb.service: Unit influxdb.service not found.

You are blindly starting influxdb with systemctl but not actually looking at whether itā€™s actually starting up.

sudo systemctl status influxdb

On your reinstall the installer failed to write to /usr/bin/influx for some reason. Did you run openhabian_config with sudo?

I was able to get it to work after a few removes and reinstalls. It was a permissions issue with dpkg not being able to unpack the zip file.

I have a small problem with the grafana graphs in openhab.
I use the webview to display them on in my basic UI but there is a small icon at the top showing that something can not be displayed.
See picture - any idea?

Hi,
Today Iā€™ve tryed to install influxdb+grafana via the openhabian-config tool.
Unfortunatelly it breaks with ā€œNot found grafanaā€¦ā€


I have a NUC with Debian 9.9 and the newest openHAB 2.
Can anybody help me?
Thanks
Henry

The instructions for installing Grafana on Debian via apt are located here. There are several commands listed that you must run before you can use the apt install.

If you upgrade to Debian buster and your " ā€¦as ā€˜Imageā€™ Element" images no longer work, while you see msg=ā€œPhantomjs exited with non zero exit codeā€ in your grafana.log, setting
OPENSSL_CONF=/etc/ssl
in /etc/default/grafana-server may work around this issue for you.
This comes from https://github.com/grafana/grafana/issues/17588
Maybe it will help someone to find the workaround quicker than I didā€¦

1 Like

Hi John,
Many thanks for your help. Iā€™ve followed all instructions but install doesnt work:
grafik
Where is grafana :slightly_smiling_face: ?
Is ```
ā€œdeb https://packages.grafana.com/oss/deb stable mainā€

the right path?
Many thanks in advance!
Henry

Thanks for the tutorial,I was able to set it up on my Raspberry Pi using MySQL instead of InfluxDB.
However I want to ask a few questions:

  • What is the performance for you on RPi? For me it takes 10-30 secs to load a 1 day graph. I would be happy if this would be almost instant. Viewing on the Grafana Dashboard it loads instantly, only the direct rendered image takes a lot of time to load

  • All of my graphs are truncated like this. The graph is not reaching the left axis. It doesnā€™t really matter if I change any parameter. Why is that?

Thanks for everyone!

That is probably the best you can expect from an RPi. And if you add many more charts, you will probably start crashing OH itself. The library that renders the images is not RPi friendly. But even on a very powerful machine, it takes me about 10 seconds to generate 5 charts. It appears instantly in Grafana because it isnā€™t generating a JPG, itā€™s actually drawing it on screen.

I would guess you have no data stored before 11:50(ish) in your database.

That would be better, Iā€™m still moving to a more powerful machine.

Yes it looks like. However not, I have data to months back now, I even checked it in MySQL. Also doesnā€™t change nothing if I ā€˜zoomā€™ the time axis. For example if Only the last 6 hours would be shown (from 16:00 at the picture above) I will still get this white screen at the beginning. Also I found out just now that timestamps are not correct for all charts. Some charts shows midnight almost midnight now, some only 22:00 (which is the current time nowā€¦).

I moved Grafana to my Windows server insted of using the Rpiā€¦ Rendering 2-3 charts on the Rpi crashed java (and openhab). After moving Grafana to my (actually a rather old dual core E6350) it takes aprox 5-6 seconds to render 3 charts.

I know that InfluxDB+Grafana is a powerful combination but is there a lightfull way for graphing on an rpi? For me it is a common function to have in a home automation system.

You can use rrd4j insted and charting in sitemaps. It requires less resources, but not that flexible though.

Ok. Thanx. I will give a try.

Hmm, I have an older laptop, I might try just running Grafana on that oneā€¦

Its a good way to try/test it. IĀ“m very pleased with how Grafana runs on my windows server. Very fast and simple setup, and hardly take any resources. IĀ“ll never ever again have it run on a Rpi or simular againā€¦

When moving over on the right part, a scroll line appear!
Without move-over there is NO hint that there are more lines!

Itā€™s even harder in the Android app, where the scroll bar never appears.
I did not yet find a full solution for this issue, but only some workarounds.
Most of them depend on the height of the graph.
In grafana web interface you can increase height by pulling the handle down.
When using the embedded image method, you can work with &height=700 or the like.
When using the webview library by wborn, you can play with the height parameter in html/panel-300px.css.
The higher the panel is, the more space you have in the legendā€¦
If someone has a better solution for this (meaning that the legend is always shown completely), Iā€™ll very interested in this.

Update:
I just found the root cause and in consequence another workaround:
The root cause can be found in /usr/share/grafana/public/sass/components/_panel_graph.scss. There you find the following (reduced to relevant lines):

.graph-panel__chart {
  min-height: 65%;
}
.graph-legend {
  max-height: 35%;
}

This implies, that the legend can only take 35% of the output. If you change this from 65/35 to 10/90, the legend will usually be displayed completely.
One little problem: the above sccs file seems to be there for information only but it has to be compiled first.
For this you can either install the source distribution and compile it yourself, or you go the ugly way, that I took for testing and this is to patch /usr/share/grafana/public/build/grafana.light.9d62d98149547e1107ad.css (or how the file you are using is named, maybe the dark one).
This isnā€™t very well readable, but with a good editor like emacs you will be able to find and replace the two numbers above.
Now a restart of grafana-server may be necessary.

To see an effect with the wborn webview, you need to set render=true (which breaks the horizontal scrolling in my Android app for the legend :frowning: )

Thanks for posting this. That really saved me a lot of time!

Hello,

I seem to have lost access to my Grafana reports some weeks ago (I believe it is as the occasion of the upgrade of Grafana via apt-get upgrade).

What I get is a white page when I access http://my.openhab.ip.address:3000
Some info on the status of the grafana server and the netstat:

[00:13:30] openhabian@openHABianPi:~$ sudo systemctl status grafana-server
ā— grafana-server.service - Grafana instance
   Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; enabled)
   Active: active (running) since Sun 2019-07-21 00:10:08 CEST; 7min ago
     Docs: http://docs.grafana.org
 Main PID: 23016 (grafana-server)
   CGroup: /system.slice/grafana-server.service
           ā””ā”€23016 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-server.pid cfg:default.paths.logs=/var/log/grafana cfg:default.paths.data=/var/lib/grafana cfg:def...

Jul 21 00:10:09 openHABianPi grafana-server[23016]: t=2019-07-21T00:10:09+0200 lvl=info msg="Starting DB migration" logger=migrator
Jul 21 00:10:09 openHABianPi grafana-server[23016]: t=2019-07-21T00:10:09+0200 lvl=info msg="Executing migration" logger=migrator id="copy data account to org"
Jul 21 00:10:09 openHABianPi grafana-server[23016]: t=2019-07-21T00:10:09+0200 lvl=info msg="Skipping migration condition not fulfilled" logger=migrator id="copy data account to org"
Jul 21 00:10:09 openHABianPi grafana-server[23016]: t=2019-07-21T00:10:09+0200 lvl=info msg="Executing migration" logger=migrator id="copy data account_user to org_user"
Jul 21 00:10:09 openHABianPi grafana-server[23016]: t=2019-07-21T00:10:09+0200 lvl=info msg="Skipping migration condition not fulfilled" logger=migrator id="copy data account_user to org_user"
Jul 21 00:10:09 openHABianPi grafana-server[23016]: t=2019-07-21T00:10:09+0200 lvl=info msg="Starting plugin search" logger=plugins
Jul 21 00:10:10 openHABianPi grafana-server[23016]: t=2019-07-21T00:10:10+0200 lvl=info msg="Initializing Alerting" logger=alerting.engine
Jul 21 00:10:10 openHABianPi grafana-server[23016]: t=2019-07-21T00:10:10+0200 lvl=info msg="Initializing CleanUpService" logger=cleanup
Jul 21 00:10:10 openHABianPi grafana-server[23016]: t=2019-07-21T00:10:10+0200 lvl=info msg="Initializing Stream Manager"
Jul 21 00:10:10 openHABianPi grafana-server[23016]: t=2019-07-21T00:10:10+0200 lvl=info msg="Initializing HTTP Server" logger=http.server address=0.0.0.0:3000 protocol=http subUrl= socket=
[00:17:42] openhabian@openHABianPi:~$ sudo netstat -tulpn4 | grep 3000
[00:17:56] openhabian@openHABianPi:~$

I guess something went wrong with the upgradeā€¦ and grafana is not restarting properly, and does not get to the point of listening on port 3000? Any opinion on what I should do to get back to normal?

Thanks,