InfluxDB+Grafana persistence and graphing

I have a stack of items I want to graph as part of the Matrix Theme that patrick setup and ive been following the tutorial. My systeminfo items are all OpenHAB_XXXX

Am I right in saying this strategy is sufficent to allow population of the items into Grafana for me to log?


Strategies {
    everyMinute : "0 * * * * ?"
    everyHour   : "0 0 * * * ?"
    everyDay    : "0 0 0 * * ?"
}

Items {
    OpenHAB_*                           : strategy = everyChange
}
kris@OpenHAB:/etc/openhab2/services$


I’m new to all this. Sorry for the silly questions!

Thanks

The * is not a wildcard that can be applied to the Item names. It is used for <groupName>*
You should create/define/use a Group, assign all Items that you would like to persist their states to that Group and then persist the Group members.

/etc/openhab2/persistence/influxdb.persist

Strategies {
    everyHour : "0 0 * * * ?"
    everyDay  : "0 0 0 * * ?"

    default = everyChange
}

Items {
    // persist all members of gInfluxDB Group on:  everyChange, everyHour, everyDay
    gInfluxDB* : strategy = everyChange, everyHour, everyDay
}

In your items:

Group		gInfluxDB
itemtype	itemname "labeltext [stateformat]" <iconname> (gInfluxDB) [...]

Ref: https://www.openhab.org/docs/configuration/persistence.html#items

Thanks. I’ve made those changes.

I see in the log, maybe unrelated

15:47:57.674 [ERROR] [ysql.internal.MysqlPersistenceService] - mySQL: Unable to find table for query 'gInfluxDB'.

why mySQL ? :slight_smile: that’s a competitor to our beloved InfluxDB !!! :stuck_out_tongue:
is your file called /etc/openhab2/persistence/influxdb.persist ?

Success :smiley: I can see the openHAB items in the Grafana webUI :smiley: Thank you Dim

1 Like

tip: you can nest groups if you would like. Assign the sub-groups to the main group that is used in your persistence config (the gInfluxDB)

For example:
Put all systeminfo items in a gSysInfo group and then make that group a member of the big gInfluxDB Group.

Group		gInfluxDB
Group		gSysInfo	(gInfluxDB)
itemtype	itemname	"labeltext [stateformat]" <iconname> (gSysInfo) [...]

For more info, see:

  1. Design Pattern: Group Based Persistence
  2. YAGSA - Yet Another Group Structure Approach

I dont even know why mySQL is there - maybe its in use for something else.

Thanks for the group info!

Now I just need to work out why theres no data in my graph :smiley:

1 Like

It seems that you have also installed in parallel the MysqlPersistenceService.
If you are not using it, uninstall it from PaperUI (Add-ons->Persistence)
You can have of course multiple Persistence Services running.

:slight_smile:

I think its in use for something else. Ill find out why.

1 Like

Just to let you know, @Confectrician and @jswim788
Things seems to be working just great now, after I changed to persistens file on your suggestions… Thank you both very much!

1 Like

Hi Guys,

Im using iframe in my Custom Widget which displays the graph correctly but it doesnt appear dynamic. I can see its updating in the webui of Grafana but not in my HabPanel widget. Any ideas?

Thanks
Kris

Hi All,

Ive added some new items with group ‘gSpeedtest’ , here is my persistence file. Grafana doesnt appear to show the items and if i show measurements in the influx client they are not listed…

Strategies {
    everyHour   : "0 0 * * * ?"
    everyDay    : "0 0 0 * * ?"

    default = everyChange
}

Items {
// persist all members of gInfluxDB Group on: everyChange, everyHour, everyDay
    gInfluxDB*,gSpeedtest*  : strategy = everyChange, everyHour, everyDay
}

I restarted grafana-server & influxdb

Any thoughts?

Sometimes when changing Persistence config, you need to restart OH

1 Like

Thanks Vincent, ill give that a go!

Unfortunately that didnt fix it :frowning:

try using 2 separate lines (this shouldn’t be the problem…)

    gInfluxDB* : strategy = everyChange, everyHour, everyDay
    gSpeedtest* : strategy = everyChange, everyHour, everyDay

or make gSpeedtest a member of gInfluxDB

Make sure that the Items included in the gSpeedtest group have a valid state (check from the console or REST)

1 Like

I checked about 1hr later and Grafana can see the items now :slight_smile: seems it needed some time ha.

1 Like

Am I right in saying a direct rendered image from Grafana will refresh it self using the following in HabPanel?

Is there anything further in Grafana I need to do to allow the graphs to refresh :frowning:

    <div class="graph">
    			<img width="250" height="200" src="http://192.168.0.3:3001/render/d-solo/7uU68LHiz/system-info-graphs?refresh=1m&panelId=16&orgId=1&from=1529315924660&to=1529920724660&tab=axes&width=250&height=200&tz=UTC%2B10%3A00" />
     			<div class="legend">Last 24 hours</div>
    </div>

I can’t seem to get the Webview working outside of my LAN. Image works fine, but the Webview just fails to load and I get an empty iframe in BasicUI (in Chrome). Here is the relevant code:

html/chartsDay.html

<!DOCTYPE html>
<html>
<head>
        <meta http-equiv="Content-type" CONTENT="text/html; charset=utf-8">
        <link rel="stylesheet" type="text/css" href="charts.css" />
</head>

    <div class="container">
        <iframe src="http://192.168.1.2:3000/d/Xlu8IxNik/test?orgId=1&from=now-24h&to=now&panelId=4"></iframe>
    </div>
  </br>
</html>

sitemap:

Webview height=33 url="http://192.168.1.8:8080/static/chartsDay.html"

Is this because I am using a reverse proxy? How can I get the Webview elements to load outside my LAN? Note that, even inside my LAN, using my FQDN to connect to OpenHAB does not load the Webview. This points to something wrong with the reverse proxy, I guess? How can I get this working?

Edit:
If I inspect the source of the BasicUI frame that is supposed to contain the Webview, these lines stick out to me:

........
<html class=" ui-layout-condensed ui-icons-enabled ">
<div class="mdl-form__row mdl-form__row--height-auto mdl-cell mdl-cell--12-col ">
	<div
		class="mdl-form__control mdl-form__webview"
		data-control-type="webview"
		data-widget-id="020300"
	>
		<iframe src="http://192.168.1.8:8080/static/chartsDay.html" height="36"></iframe>
	</div>
</div>

Does the Webview simply “pass on” the link to the html file, without loading any of the resources that html file calls on? (Please excuse my imprecise terminology).

If the Webview is just passing a link to the html file, I can’t see how anyone has gotten this working without putting a FQDN in their Webview, and then exposing Grafana to the internet as well (and then changing the URLs in their html files to contain FQDNs as well).

Has anyone gotten the Webview working with their Openhab behind a reverse proxy?

You’ve specified absolute time for your graph, so it will always be the same. You probably want something like:

&from=now-24h&to=now
1 Like