InfluxDB+Grafana persistence and graphing

I found myself needing grafana on a pi 1 a few days ago and was quite unhappy to be unable to simply download it from my repo …
So I will try to provide a grafana deb package for pi1 when v4 will be published. Most of the hard work is probably already done since my poor pi 1 already suffered the build of PhantomJS.

1 Like

I got that from bundle:list on karaf.

First thing you need to make sure that the old version is uninstalled (bundle:uninstall xxx).
Then the easiest way to add a new version is to place it in the addons folder.

My fault,:blush: I did install the new bundle (which I confirmened by the timestamp), however I did not notice that the uninstall via PaperUI left the old bundle in use.

Did the test again.

Setting influxdb.cfg to “retentionPolicy=newtest” (a non-default RP) and doing a query via the REST API website does return the data that is persited into “newtest”.

In other words “LooksGoodToMe”.

Great post!
Got it working in classic UI but not in HabDroid (Android or iOS).
Did anyone manage to display graphs from Grafana in the Habdroid App?

How to make openhab 1.8 + InfluxDB 1.9 InfluxDB write in the name of the item from labeltext?
For example, now an item is as follows:
Number Humidity_8302000000000000 “Humidity Bedroom mobile1: [% .1f %%]” (PersistTemp)

And InfluxDB written Humidity_8302000000000000 key, but you need to “Humidity Bedroom mobile1”

Yes, it works fine if you use Image in your sitemap instead of Webview.

Wonderful. Would be great if you pinged me as soon as the package is available. You are also invited to create a PR :wink:

Thanks for the response @smar.
but when i try to use an Image I get the same proxy errors that @vespaman posted.

HTTP ERROR 504
Problem accessing /proxy. Reason:
Gateway Timeout

This won’t be related to a reverse proxy in a sense (you may not even have one), but related to how Jetty is serving linked content as a resource.

@Niko_Izsak Am I right in understanding that by following the guide in this tutorial you are able to create a webview to see on a PC browser but fail to see this work as an image OR webview on habdroid?

@ThomDietrich I’m guessing the invite to the conversation was for the proxy mention? I’ve never used InfluxDB or Grafana, but if people aren’t able to get this working then I will try and implement it on Sunday to see if I can spot the cause of this problem?

Hey thanks for the quick answer. I just read “proxy” and remembered another question related to tha and thought it’s nginx related.
I now looked it up and nope was something different. Don’t bother (for now)
@Niko_Izsak the image should work. Could you please test opening it manually in your browser / fetching it via wget? Also make sure the url you’ve got is correct…

Hi @ThomDietrich, I did test via browser and wget, and both work fine.
@Benjy - correct , webview works on my pc(browser) but not in Habdroid , i couldn’t get the Image item working at all(PC or habdroid)
wget:

[18:08:36] pi@openHABianPi:~$ sudo wget “http://192.168.2.3:3000/render/dashboard-solo/db/home-stats?width=480&height=240&panelId=3&from=now-1d&to=now” -O test.png
–2016-11-10 18:08:47-- http://192.168.2.3:3000/render/dashboard-solo/db/home-stats?width=480&height=240&panelId=3&from=now-1d&to=now
Connecting to 192.168.2.3:3000… connected.
HTTP request sent, awaiting response… 200 OK
Length: 16883 (16K) [image/png]
Saving to: ‘test.png’

error in openhab.log:

2016-11-10 18:05:28.872 [WARN ] [thome.ui.internal.proxy.ProxyServlet] - Proxy servlet failed to stream content due to a timeout

stiemap :

Switch item=Chart_Period label="Chart Period" mappings=[0="Hour", 1="Day", 2="Week"]
Image refresh=60000 url="http://192.168.2.3:3000/render/dashboard-solo/db/home-stats?width=480&height=240&panelId=3&from=now-1h&to=now" visibility=[Chart_Period==0]
Image refresh=60000 url="http://192.168.2.3:3000/render/dashboard-solo/db/home-stats?width=480&height=240&panelId=3&from=now-1d&to=now" visibility=[Chart_Period==1]
Image refresh=60000 url="http://192.168.2.3:3000/render/dashboard-solo/db/home-stats?width=480&height=240&panelId=3&from=now-1w&to=now" visibility=[Chart_Period==2]

I have to be missing something.

Very good write up. Now everything is clear and unclear at the same time :smile: All looks good to me.

My own influxdb+grafana setup is not on the RPi. I don’t think that’s realistic but could timeout indeed mean InfluxDB and/or Grafana are taking too long to respond? How fast is your wget for one week or even one year?

It is pretty slow to respond , so maybe WebView is the way to go. (but that is not working in Habdroid)

I dont have a year of data in InfluxDB, but for one week in takes around 8 seconds to respond:

[18:39:39] pi@openHABianPi:/etc/openhab2/html$ sudo wget “http://192.168.2.3:3000/render/dashboard-solo/db/home-stats?width=480&height=240&panelId=3&from=now-1w&to=now” -O test.png
2016-11-10 18:39:45http://192.168.2.3:3000/render/dashboard-solo/db/home-stats?width=480&height=240&panelId=3&from=now-1w&to=now
Connecting to 192.168.2.3:3000… connected.
HTTP request sent, awaiting response… 200 OK
Length: 16780 (16K) [image/png]
Saving to: ‘test.png’

test.png 100%[==================================================================================================================>] 16.39K --.-KB/s in 0s

2016-11-10 18:39:53 (75.9 MB/s) - ‘test.png’ saved [16780/16780]

8 seconds and these code lines do explain:

Could you provide proof to the contrary and check with a URL that takes less than 5 seconds to respond? If this succeeds as expected we can take measures.

couldn’t get Grafana to render an image in less than 5 seconds :disappointed:

so i tested from an example graph online , and it worked.

Image refresh=60000 url=“http://grafana.org/assets/img/blog/mixed_styles.png” visibility=[Chart_Period==0]

We need one from your server to be sure. Try a Singlestat: http://docs.grafana.org/reference/singlestat/

aslo with Signlestat it takes longer than 5 seconds.
it seems like it’s not the query , it is the image rendering part that takes long.

update - can confirm that it’s not the query , tested with a text panel, and it also takes around 6 seconds to render.

Can you tell me your Raspberry Pi model? (The name is printed in the infoscreen on ssh login)
I’ll open a request to extend the timeout.

Raspberry Pi 3 Model B Rev 1.2