InfluxDB+Grafana persistence and graphing

Perfect! Thank you! Works like a charm!

EDIT: The dynamically presented charts do not get displayed by the openhab iOS App. Is this something that can be battled? They show up in mobile safari just fine.

1 Like

I don’t use iOS myself, but also had troubles to get it to work with the Android App. Eventually I did find a way to get rendered Grafana panels working from within the App. Most likely the same approach also works with the iOS app.

Recently PR #266 to turn on DOM storage in the Android App was merged. So in the next version of the Android App (1.8.0.5) the non-rendered (Javascript) Grafana panels should also work. Perhaps something similar needs to be done to get Javascript panels working on iOS.

Hey gents,
awsome tutorial. Was a snap to get this up and running. I read some comments about broken persistance when using minimumsince() function. I started using Grafana after OH2 prod release. Not sure if the mentioned problems are still valid for the version I’m using.

Here’s the deal. I’m persisting gas prices from Tankerkönig and would like to get the cheapest price for the last 3 days. Thus I’ve setup a small rule containing:

var cheapest_sprit = diesel_jet_berliner.minimumSince(now.minusDays(3), "influxdb")
logInfo("Sprit Preise", "Der günstigste Sprit Preis seit 3 Tagen ist: " + cheapest_sprit )

This does not seem to work as I do get the following error:

2017-02-08 08:54:32.467 [INFO ] [.smarthome.model.script.Sprit Preise] - Der günstigste Sprit Preis seit 3 Tagen ist: org.openhab.core.persistence.internal.QueryablePersistenceServiceDelegate$1@773e8f99

I also setup some graphs in Grafana showing 3days history and confirming the “cheapest_sprit” by Grafanas MIN() function. Thus I can confirm, OH data is persisted correctly.

Any idea to get this working is appreciated.
Thanks much

Hi,
is it possible to display bool variables as gantt (one line with one color for value=0 and other for value=1) ?


Thanks.

OK, if I add mathematical shift *100 *98 *96 to basic bool variables then I can simulate gantt. Can displaying of basic value=0 be masked out ? Zero value should be not graphically displayed ?

Hi,

I’ve problems with starting Grafana. I’ve tried to install and uninstall a couple of times but with same errors.

Feb 22 18:13:27 openHABianPi systemd[1]: grafana-server.service holdoff time over, scheduling restart.
Feb 22 18:13:27 openHABianPi systemd[1]: Stopping Grafana instance...
Feb 22 18:13:27 openHABianPi systemd[1]: Starting Grafana instance...
Feb 22 18:13:27 openHABianPi systemd[1]: grafana-server.service start request repeated too quickly, refusing to start.
Feb 22 18:13:27 openHABianPi systemd[1]: Failed to start Grafana instance.
Feb 22 18:13:27 openHABianPi systemd[1]: Unit grafana-server.service entered failed state.

Any suggestions?

Br
Thomas

Not much to go with. Which RPi board version are you running it on? Did you google the error message? Please check the grafana log file for hopefully more info…

@Jusufs I believe nobody answered because we are not sure either. Grafana doesn’t support it so you’ll need to hack something yourself. Did you make any progress?

@waitz_sebastian I never went this way, asking influxdb for values. You may need to play around a bit. I would be interested in the results. From what you’ve posted currently your “cheapest_sprit” is not a basic datatype like String or Float. Use the SmartHome Designer to find out about methods you can on a QueryablePersistenceServiceDelegate object.

any reason why my influx stop store 1-2 items after few days, measurements around 2.5K count, I first confirm data source no issue, than no issue on openhab, value keep updated, than I try drop the stop storing measurement value, new value come out,
Platform RPI3-B with openhabian, last system update around 1 week, item should get update every minute when turn on,
problem I can’t figure out is now only have 1 item got issue (1 recovered by clear the data on that item),

I don’t think problem should due to too much value, 2.5K won’t be a issue right now right?
anyone know why I have this issue?

Hi pahansen,

i´ve tried your Webview workaround and it work great. The only thing is that i´ve to reload(F5) the browser when i want to switch the view from lets say “hour” to “day”. The switch on the sitemap works and show up the right chart, but i´ve to hit F5 to see the graph inside. Any ideas?

Are you using the basic UI? If yes, it’s a limitation of the UI.

Hi,

yes i use the basic ui. In which ui it will work?
Thx

1 Like

I have a basic question about Grafana. I’ve setup my ZWave items with “everyChange” in the persist file to save disk space. The problem now is that some devices are only sending a few values every day. This looks currently something like this in Grafana:

Is it possible to tell grafana that it should expand the line to the beginning of the graph even if there are no data points? Or even better if I could tell grafana to also load the latest value outside the current time range for this specific line?

Until now I only found the possibility to treat missing values as null or 0 values, but that just draws the line at the bottom of the graph.

That’s normal behavior of Grafana in combination with InfluxDB. Grafana queries only measurements inside the visible time window and will only draw a graph where it is certain what to graph. That’s why you’ll find empty space to the left and the right. I don’t know of any way to tell Grafana to look for measurements outside the visible time window (which would be the solution)

Either you live with this limitation (which is okay for most series as you’ll look at them with a big time range mostly) or you add “everyHour” to your persistence strategy.

Hey,
I love Influx/Grafana and do use it at work for graphing monitoring metrics. I just stumbled upon a very interesting project called Histou which adds custom dashboards to Grafana using templates. One can pass parameters to the framework via URL and it automatically creates Grafana graphs without the need of having them defined prior to watching.
This sounds like a perfect use-case for openhab, right? Only parsing the item.name via URL and render a perfect default graph in Grafana.
Possibly someone with some more coding skills would be able to fork the project and adapt it to openhab needs?! I’d be happy to help with testing, etc but I’m lost in the source-code.

Here’s the project link to Histou

3 Likes

Hello , i need your help . I’ve installed influxdb and grafana in openhabian on rpi3.
Works fine but … I can’t run influxdb as service.
When i connect to my host with ssh and type influx to acces the cli , i’ve this:

_> Failed to connect to http://localhost:8086: Get http://localhost:8086/ping: dial tcp 127.0.0.1:8086: getsockopt: connection refused_

_> Please check your connection settings and ensure 'influxd' is running._

If i type influxd the server starts but if i close the shell it stops and everything is lost.

_> [07:15:06] openhabian@openHABianPi:~$ influxd_

_>  8888888           .d888 888                   8888888b.  888888b._
_>    888            d88P"  888                   888  "Y88b 888  "88b_
_>    888            888    888                   888    888 888  .88P_
_>    888   88888b.  888888 888 888  888 888  888 888    888 8888888K._
_>    888   888 "88b 888    888 888  888  Y8bd8P' 888    888 888  "Y88b_
_>    888   888  888 888    888 888  888   X88K   888    888 888    888_
_>    888   888  888 888    888 Y88b 888 .d8""8b. 888  .d88P 888   d88P_
_>  8888888 888  888 888    888  "Y88888 888  888 8888888P"  8888888P"_

_> [I] 2017-03-06T06:15:39Z InfluxDB starting, version 1.2.0, branch master, commit b7bb7e8359642b6e071735b50ae41f5eb343fd42_
_> [I] 2017-03-06T06:15:39Z Go version go1.7.4, GOMAXPROCS set to 4_
_> [I] 2017-03-06T06:15:39Z no configuration provided, using default settings_
_> [I] 2017-03-06T06:15:39Z Using data dir: /home/openhabian/.influxdb/data service=store_
_> [I] 2017-03-06T06:15:39Z reading file /home/openhabian/.influxdb/wal/_internal/monitor/1/_00001.wal, size 61182 engine=tsm1 service=cacheloader_
_> [I] 2017-03-06T06:15:39Z reading file /home/openhabian/.influxdb/wal/_internal/monitor/1/_00002.wal, size 795477 engine=tsm1 service=cacheloader_
_> [I] 2017-03-06T06:15:40Z reading file /home/openhabian/.influxdb/wal/_internal/monitor/1/_00003.wal, size 405410 engine=tsm1 service=cacheloader_
_> [I] 2017-03-06T06:15:41Z reading file /home/openhabian/.influxdb/wal/_internal/monitor/1/_00004.wal, size 0 engine=tsm1 service=cacheloader_
_> [I] 2017-03-06T06:15:41Z /home/openhabian/.influxdb/data/_internal/monitor/1 database index loaded in 5.533469ms service=shard_
_> [I] 2017-03-06T06:15:41Z /home/openhabian/.influxdb/data/_internal/monitor/1 opened in 1.757146167s service=store_
_> [I] 2017-03-06T06:15:41Z opened service service=subscriber_
_> [I] 2017-03-06T06:15:41Z Starting monitor system service=monitor_
_> [I] 2017-03-06T06:15:41Z 'build' registered for diagnostics monitoring service=monitor_
_> [I] 2017-03-06T06:15:41Z 'runtime' registered for diagnostics monitoring service=monitor_
_> [I] 2017-03-06T06:15:41Z 'network' registered for diagnostics monitoring service=monitor_
_> [I] 2017-03-06T06:15:41Z 'system' registered for diagnostics monitoring service=monitor_
_> [I] 2017-03-06T06:15:41Z Starting precreation service with check interval of 10m0s, advance period of 30m0s service=shard-precreation_
_> [I] 2017-03-06T06:15:41Z Starting snapshot service service=snapshot_
_> [I] 2017-03-06T06:15:41Z Starting continuous query service service=continuous_querier_
_> [I] 2017-03-06T06:15:41Z Starting HTTP service service=httpd_
_> [I] 2017-03-06T06:15:41Z Authentication enabled:false service=httpd_
_> [I] 2017-03-06T06:15:41Z Listening on HTTP:[::]:8086 service=httpd_
_> [I] 2017-03-06T06:15:41Z Storing statistics in database '_internal' retention policy 'monitor', at interval 10s service=monitor_
_> [I] 2017-03-06T06:15:41Z Starting retention policy enforcement service with check interval of 30m0s service=retention_
_> [I] 2017-03-06T06:15:41Z Listening for signals_
_> [I] 2017-03-06T06:15:41Z Sending usage statistics to usage.influxdata.com_
_> ^C[I] 2017-03-06T06:15:49Z Signal received, initializing clean shutdown..._
_> [I] 2017-03-06T06:15:49Z Waiting for clean shutdown..._
_> [I] 2017-03-06T06:15:49Z shutting down monitor system service=monitor_
_> [I] 2017-03-06T06:15:49Z Precreation service terminating service=shard-precreation_
_> [I] 2017-03-06T06:15:49Z snapshot listener closed service=snapshot_
_> [I] 2017-03-06T06:15:49Z continuous query service terminating service=continuous_querier_
_> [I] 2017-03-06T06:15:49Z retention policy enforcement terminating service=retention_
_> [I] 2017-03-06T06:15:49Z closed service service=subscriber_
_> [I] 2017-03-06T06:15:49Z server shutdown completed_

I’ve tried to start it with systemctl but seems to me the same problem:

[07:15:49] openhabian@openHABianPi:~$ sudo systemctl start influxd
[sudo] password for openhabian:
[07:17:07] openhabian@openHABianPi:~$ systemctl start influxd
Failed to start influxd.service: Access denied
[07:17:13] openhabian@openHABianPi:~$ sudo systemctl start influxd
[07:17:23] openhabian@openHABianPi:~$ influx
Failed to connect to http://localhost:8086: Get http://localhost:8086/ping: dial tcp 127.0.0.1:8086: getsockopt: connection refused
Please check your connection settings and ensure 'influxd' is running.

The service status tell me this:

[07:17:39] openhabian@openHABianPi:~$ sudo service influxd status
● influxdb.service - InfluxDB is an open-source, distributed, time series database
   Loaded: loaded (/lib/systemd/system/influxdb.service; enabled)
   Active: failed (Result: start-limit) since Mon 2017-03-06 07:17:24 CET; 56s ago
     Docs: https://docs.influxdata.com/influxdb/
  Process: 20225 ExecStart=/usr/bin/influxd -config /etc/influxdb/influxdb.conf ${INFLUXD_OPTS} (code=exited, status=1/FAILURE)
 Main PID: 20225 (code=exited, status=1/FAILURE)

Mar 06 07:17:24 openHABianPi influxd[20225]: [I] 2017-03-06T06:17:24Z Influx...2
Mar 06 07:17:24 openHABianPi influxd[20225]: [I] 2017-03-06T06:17:24Z Go ver...4
Mar 06 07:17:24 openHABianPi influxd[20225]: [I] 2017-03-06T06:17:24Z Using ...f
Mar 06 07:17:24 openHABianPi influxd[20225]: run: parse config: open /etc/in...y
Mar 06 07:17:24 openHABianPi systemd[1]: influxdb.service holdoff time over,....
Mar 06 07:17:24 openHABianPi systemd[1]: Stopping InfluxDB is an open-source....
Mar 06 07:17:24 openHABianPi systemd[1]: Starting InfluxDB is an open-source....
Mar 06 07:17:24 openHABianPi systemd[1]: influxdb.service start request repe....
Mar 06 07:17:24 openHABianPi systemd[1]: Failed to start InfluxDB is an open....
Mar 06 07:17:24 openHABianPi systemd[1]: Unit influxdb.service entered faile....
Hint: Some lines were ellipsized, use -l to show in full.

and

[07:21:35] openhabian@openHABianPi:/etc/influxdb$ ps -ef|grep influx
openhab+ 20417 19848  0 07:22 pts/0    00:00:00 grep --color=auto influx

Please help . Thanks.

@RGB73

Your missing b when trying to start influxdb. It should be

I am also new with InfluxDB and Grafana. I followed the guide at the top of post and believe I did everything correct, yet I get nothing showing with the SineWave test data.

I edited and ran the python script to add data and the terminal reports that data be adding in groups of 5.

And I setup my dashboard as follows? openhab_home is the name of source.

Edit… Nevermind. Being new to Grafana and learning, I was unaware you need to set the date periods in the upper right of the chart to see the information. Next step to try and get OH2 data into it.

I’ll try this evening.

I’ve got the same error.

[11:34:45] openhabian@openHABianPi:~$ sudo systemctl start influxdb
[sudo] password for openhabian:
[11:35:16] openhabian@openHABianPi:~$ influx
Failed to connect to http://localhost:8086: Get http://localhost:8086/ping: dial tcp 127.0.0.1:8086: getsockopt: connection refused
Please check your connection settings and ensure 'influxd' is running.

The status is

[12:01:06] openhabian@openHABianPi:/etc$ systemctl status influxdb.service
● influxdb.service - InfluxDB is an open-source, distributed, time series database
   Loaded: loaded (/lib/systemd/system/influxdb.service; enabled)
   Active: failed (Result: start-limit) since Wed 2017-03-08 12:00:47 CET; 21s ago
     Docs: https://docs.influxdata.com/influxdb/
  Process: 15527 ExecStart=/usr/bin/influxd -config /etc/influxdb/influxdb.conf ${INFLUXD_OPTS} (code=exited, status=1/FAILURE)
 Main PID: 15527 (code=exited, status=1/FAILURE)

OK i found the problem that influxd doesn’t start as service … is relative to permissions.
cd /lib/systemd/system
looking at the file influxdb.service with the command
sudo nano influxdb.service

[Service]
User=influxdb
Group=influxdb
LimitNOFILE=65536
EnvironmentFile=-/etc/default/influxdb
ExecStart=/usr/bin/influxd -config /etc/influxdb/influxdb.conf ${INFLUXD_OPTS}
KillMode=control-group
Restart=on-failure

i see that starts /usr/bin/influxd with the config file /etc/influxdb/influxdb.conf
If i look at /usr/bin/influxd
i see
root root 15M Jan 24 04:24 influxd*
so permission are as root.
I’ve changed
User=root
Group=root
than
sudo systemctl daemon-reload
and start influxdb as service with
sudo systemctl start influxdb

For me it works. Have a nice day.

2 Likes

How i can install library and all necessary file ?