InfluxDB+Grafana persistence and graphing

hi @joriskofman
I do not use myopenhab, I don’t like it and it was too slow. At my house I have 100Mbit connection and I prefer to have openhab hosted in house, on my local server.
I don’t know myopenhab utentication method, but if it support authentication passed by a revese proxy, I think it in possible to integrate. You can also configure grafana to bypass login, using a RP passing fixed credential.

Regards

Marco

That’s a massive tutorial.
Thanks for sharing.
Possibly an excellent project for my next vacation :wink:

1 Like

I was curious if anyone else has had a problem sense updating to OpenHAB 2.1 (from 2.0). Grafana is not finding any data points since the day I upgraded.

I have verified that Influx is collecting new data via the CLI.
I did the update using openhabian-config.
I have double checked all of the settings and setup as listed in this topic.

Any help would be appreciated.

Thanks,

Dave

I was wondering if anybody has the same experiance with InfluxDB taking very much memory on my Raspberry Pi 2.

I am running openhab2.1 as a nativ installation and InfluxDB and Grafana as docker containers.
There are about 80 series/items stored in the openhab_db.

As you can see in the following graph, InfluxDB is using about 150-300MB os memory.

This is the overall memory usage of my Pi. :frowning:

The System is working fine, but I don’t think this is “healthy”.

So: Is this normal for InfluxDB?
Does anybody running a similar setup?
Are there usefull parameters to tweak the memory usage of InfluxDB?

Databases are memory his as a general rule. 200-300 mg of RAM does not alarm me. I think it is online with what I’m seeing (I’m on my phone and the font on my shoulder client is REALLY small so I’m not sure I added up all the processes). They take up a lot of your available open file handles as well (I discovered this when I tried to put the InfluxDB data on a CIFS mounted volume and ran out.

In case anyone had the same problem, this topic gave me some hints: MapDB giving weird error. I ended up deleting influxdb.persist and creating a new file. It appears to have solved the problem.

@ThomDietrich 's tutorial is covered by timeShift (Grafana’s blog series with articles from the community) :fireworks:

Summer time reading :parasol_on_ground: :slight_smile:

Implement your own http://play.grafana.org Dashboard with openHAB 2 !

4 Likes

Nice! :slight_smile:

1 Like

I don’t know what your experiences are, but I would advice against running openhab2 and influxdb on the same RaspberryPi.

I had it running on a RasPi2 for a few weeks now, but the memory usage is just to heavy.
InfluxDB was using about 300MB and openhab had to reload some rule files with resulted in unexpected behavior.

Maybe there should be a warning here. InfluxDB+Grafana persistence and graphing

Just my 2 cents.
Maybe there is a way to make it work, but I donÄt know it. :wink:

3 Likes

just fyi (a data point):
today all 3 components were upgraded (using apt) in my Debian Jessie main system:
OH 2.2.0 Snapshot from Build # 1003 to 1006
Grafana from 4.4.2 to 4.4.3
InfluxDB from 1.3.1-1 to 1.3.2-1

All work fine :slight_smile:

1 Like

Thanks for the info! I’ve updated the first post.

1 Like

Hi,
very nice guide.
I am using OpenHab & InlfuxDB & Grafana to track some data i.e. Temperature and Energy consumption.

In Grafana there is the possibility to show on the graph legend the average, min and max value inside a determined period of time (i.e Last 24h)

I would like to send this data to an OpenHab Item (i.e. Temp_Avg_Last24h). Is it posssible and how?

Regards
Lorenzo

Hello @Foxejoe, that’s not possible directly as these are specific queries generated by grafana to display your desired value.
However, you are free to query whatever you want to from InfluxDB yourself. Check out the InfluxDB documentaiton on how to retrieve such measures, then build a corresponding rule.

Check out: How to store / query Influxdb from OH?

Please post your solution and I’d be happy to add a section to this tutorial!! Thanks

1 Like

In theory, by using a dummy item and a rule with averageSince you could get such data into your sitemap.
Search the forum for averageSince examples.

1 Like

Thanks,
I see there is also example on OH1 wiki for persistance in Rules.
if I well understand the rules for avg temperature on the last 24h should be something like::

rule "Temperature Average"
when
Item Temperature received update
then
Temperature_Avg.postUpdate(Temperature.averageSince(now.minusHours(24)))
end

Correct?

Is there also a method to get the avg temperature from a defined period (i.I.e. from 1/1/2017 to 1/2/2017)?

Regards
Lorenzo

Hi, I tried to use this tutorial to get the grafana+influxDB combo running on my raspberry pi together with openhab 2. I am struggling with grafana though.
I have set up influxDB and added a grafana and an openhab user. It is already connected to openhab and data is written to the openhab_db database. I also installed grafana and changed the settings .ini file according to this tutorial. Then I logged in with the grafana admin account to the server:3000 grafana website.
Now my problem is creating the influxdb datasource. I selected influxdb and added the url. I also checked the basic auth option and that is where the problems start: which user do I have to enter here? The influxDB grafana user? The grafana admin user? I tried both and get the same problem.
In the influxDB Details part I added the database and grafana user for the influxDB. Clicking save & test shortly displays a progressbar but then keeps spamming me with a “authentification needed” popup.

Why is that? I am already logged in.
Can anyone help solving this or had similar problems? Thank you!

Ok I fixed the problem… turns out I somehow made an error while creating the grafana user in the influxDB. I set the password a second time and now everything is working just fine. If someone has similar problems I recommend testing the users ability to request data via curl commands (there are explanations on how to do this in the influx manual).

1 Like

Okay I got a strange Issue. My Influx does not store any data.
If I look at the Karaf logs (I set org.openhab.influxdb to TRACE) I only get the log from startup

13:48:58.430 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘influx.persist’

Nothing more.
At this point I dont know what the problem could be.
I use
Item101 : strategy = everyChange, everyDay, restoreOnStartup

use the full path:

log:set TRACE org.openhab.persistence.influxdb

If you are on OH 2.2.0 S1025 you may have some issues (it seems that build 1025 has some problems)

@Dim Thanks for that

15:40:44.016 [DEBUG] [org.openhab.persistence.influxdb ] - BundleEvent STARTING - org.openhab.persistence.influxdb
15:40:44.017 [DEBUG] [.InfluxDBPersistenceServiceActivator] - InfluxDB persistence bundle has been started.
15:40:44.018 [DEBUG] [org.openhab.persistence.influxdb ] - BundleEvent STARTED - org.openhab.persistence.influxdb
15:40:44.030 [DEBUG] [org.openhab.persistence.influxdb ] - ServiceEvent REGISTERED - {org.openhab.core.persistence.PersistenceService, org.openhab.core.persistence.QueryablePersistenceService}={service.pid=org.openhab.influxdb, db
=openhab_db, user=openhab, url=http://127.0.0.1:8086, password=youSneekyLittle, component.name=org.openhab.persistence.influxdb, retentionPolicy=autogen, component.id=207, service.id=331, service.bundleid=211, service.scope
=bundle} - org.openhab.persistence.influxdb
15:40:44.044 [DEBUG] [.internal.InfluxDBPersistenceService] - influxdb persistence service activated

So but what is the problem…

5:44:05.124 [DEBUG] [.internal.InfluxDBPersistenceService] - database status is OK, version is 1.3.3
15:44:05.127 [DEBUG] [org.openhab.persistence.influxdb ] - ServiceEvent REGISTERED - {org.openhab.core.persistence.PersistenceService, org.openhab.core.persistence.QueryablePersistenceService}={service.pid=org.openhab.influxdb, db
=openhab_db, user=openhab, url=http://127.0.0.1:8086, password=youSneekyLittle, component.name=org.openhab.persistence.influxdb, retentionPolicy=autogen, component.id=207, service.id=331, service.bundleid=211, service.scope
=bundle} - org.openhab.persistence.influxdb