InfluxDB+Grafana persistence and graphing

I tried this procedure many times. I know the hard work to maintain this, but after reading almost all the posts, I’ve seen that we could avoid a part of this procedure by using the openhab-config option. But as I’m new on this, I still have problems to understand Right management, that means even after loggin to influx with sudo , without sudo, with all my hope, I get the following message when I try to do a basic function like SHOW DATABASES:

ERR: authorization failed
Warning: It is possible this error is due to not setting a database.
Please set a database with the command "use <database>".

So if the script that’s launch the installation of Grafana and InfluxDB is not fully complete, this that I can understand, what are the commands I need to lauch? I tried some, but still the same message with the wrong rights.

My grafana installation seems ok as I’m able to install Darksky plugin and play with graphs, I also installed the persistence, but when I try to connect from Grafana interface InfluxDB, no hope, as I even do not know if the db was correcty created. Using latest dev 2.5.x on RBIP3+
Thanks in advance.

OK, Reply to myself… After investigating through the forum, I’ve seen this post and now for those who encountered the same problem, beware, the script installing InfluxDB and Grafana doesn’t do all the job. DATABASE is not installed!
In my case, after a clean install, I had to proceed this way:

sudo chown -hR openhab:openhab /etc/openhab2
sudo chown openhab:openhabian /etc/openhab2/services/influxdb.cfg
influx -port 8086 -username myusername -password mypassword -host localhost

CREATE DATABASE openhab_db
CREATE USER myusername WITH PASSWORD 'mypassword' WITH ALL PRIVILEGES
CREATE USER openhab WITH PASSWORD 'myopenhabpassword'
CREATE USER grafana WITH PASSWORD 'mygrafanapassword'
GRANT ALL ON openhab_db TO openhab
GRANT READ ON openhab_db TO grafana

@ThomDietrich I know it’s hard to maintain documentation, and I appreciate what has been done but it would be easy to copy these lines at the beginning of the topic, it would help Beginners like me. :upside_down_face:

8 Likes

Hi, I cant get this to work.

influx -port 8086 -username myusername -password mypassword -host localhost

is “myusername” and “mypassword” random becauce it still says “authorization failed”

this are the username and password values you choosed during db installation process.

Hi All .
This might be the wrong place to ask. but I have a problem .
when I open the graphs on my iPhone on the iOS app. it gives me a error and it does not show the graphs .just a whit screen and when I open it up on basic ui on myopenhab I just get a square with a question mark in it.

Does anyone else here got the same problem with the latest grafana version that you’re unable to display your graph anymore by pasting the embeded link into a frame.

It won’t show at all, seems that there are more people with this problem, did anyone here already found a solution: https://community.openhab.org/t/grafana-not-showing-in-habpanel-error-in-dev-console/47022/10

I did for awhile but before I could investigate it started to work. I’d probably done a couple of upgrades after I first noticed the behavior so maybe an upgrade is needed. NOTE: I did not upgrade openHAB, was running 2.5 M1 the whole time.

The behavior I saw was that even when on my LAN, the graphs in BasicUI said that Grafana refused the connection. Pulling up the Grafana dashboard and pulling up the embedded link in a browser worked just fine.

I had the same problem, when investigating I found in /etc/grafana.ini an option:

# set to true if you want to allow browsers to render Grafana in a <frame>, <iframe>, <embed> or <object>. default is false.
allow_embedding = true

I uncommented this option and set it to “true”, after a grafana restart basicui showed the graphs again.
I think this is an older option but why it suddenly activated is beyond me…

It’s a new security “feature” introduced with Grafana 6.2.
The solution to this problem is quite easy.

4 Likes

Just in case someone else loses their embedded grafana panels following a grafana upgrade due to a “X-Frame-Options is set to false” error, I found a solution. It is the same solution outlined by @derkens with a twist. I had to actually add the “allow_embedding=true” statement to my /etc/grafana/grafana.ini config file under the file’s [security] section (i.e. it was not there to uncomment). See documentation for more info. If you add the statement to any section other than the [security] section it may not work. Of note, I’m using openhabian 2.4.0-1 w/ grafana 6.2.4 and influxdb

I can confirm that is correct. If you are running in Docker or configuring Grafana using environment variables instead of the config file, you would use GF_SECURITY_ALLOW_EMBEDDING=true.

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!