New Add-on bundle for Prometheus health Metrics

Hello,
because the existing exporter didn’t suit my needs, i’ve written another one.
https://github.com/gfournetfayas/openhab2-exporter.git
Wrotten in Go, it follows the Prometheus standards.
It is based on the REST API of OpenHAB.
I’ll add stuff to the repo soon (service file for systemctl, grafana dashboard example).
All feedbacks are welcome !

Hello,

I’ve recently had a java heap problem on my openhab and I was looking for a way to monitor it. The great @rlkoshak pointed out this project and it looks very great.

Unfortunately, like others have mention, it doesn’t work on my openhab 2.4 (openhabian on raspberryPi 3)

I followed the instruction of @ricadelic but the problem is the installation of the .jar. For the three simpleclient*.jar, i’ve got no log and i didn’t find any trace of them in karaf (in feature or bundle). Then the last jar, for prometheus-metric give me this error:

2019-10-29 20:00:24.597 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/com.kuguhome.openhab.prometheusmetrics-2.4.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: com.kuguhome.openhab.prometheusmetrics [281]
  Unresolved requirement: Import-Package: io.swagger.annotations; version="1.5.7.SNAPSHOT"

	at org.eclipse.osgi.container.Module.start(Module.java:444) ~[?:?]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[?:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1221) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:515) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [10:org.apache.felix.fileinstall:3.6.4]

And when I try the web page it says:

{"error":{"message":"HTTP 404 Not Found","http-code":404,"exception":{"class":"javax.ws.rs.NotFoundException","message":"HTTP 404 Not Found","localized-message":"HTTP 404 Not Found"}}}

Is there something we can do about that bundle on 2.4?

1 Like

Hi all,

In 2.5.2 i got the same error as described above (New Add-on bundle for Prometheus health Metrics) . Has anyone managed to make the bunle compatible again?

just to update this great set of instructions:

the links to the dependencies appear to be broken. Here are some working links:

since “new users” are only allowed to improve this conversation with two links at a time, I have to split the post, sorry…

… continuing:

I also needed this package on openHAB 2.5.9 in Docker:

Installing this lead to a restart of HABmin/HABpanel but I noticed no changes so far.

The dependencies are quite outdated, is it possible to run more uptodate versions?

I got the Prometheus exporter running but it finally stopped working with OH3.
Fiddling with the really outdated dependencies I ended up doing a complete rewrite. Since there was already an initiative to add metrics to the openHAB core this resulted in two PRs (one to the OH core, one to introduce a new addon to provide the metric endpoint):

I got the whole chain running in a development build, see some resulting screenshots here:

If anyone is interested in testing this, I can provide you with dev builds of the OH distribution and the addon.

3 Likes

Here are the preview builds:

Unzip the distribution and place the metrics IO addon into the addons folder. (The addon will not work in the latest official Openhab release yet).

The metrics will then be available under /metrics/prometheus.
You’ll need to set up Prometheus and Grafana to have some charts, obviously :stuck_out_tongue:

Additional information and a sample Grafana dashboard is available in the Readme of the addon.

Please get back to me if you feel there is information missing so I can add it to the Readme.

Update
I documented a way to install this for existing installations (Openhabian) by replacing the core Monitor bundle and adding the new Metrics IO addon:

So no excuses anymore :stuck_out_tongue:
Have fun!

Original post

Here is another preview build of the addon where I included support for InfluxDB:
…removed the link due to a newer one being available…

I thought this might be especially interesting since the openhabian distro also includes an option to install Influx (but the openHAB core changes have to be released to openhabian for this to work).

1 Like

I guess that a standardized health/metrics API would make a lot of sense to take OH into a monitoring strategy. And from my feeling it should be part of the OH Core.

I’m not the expert here, but I saw some serious efforts with Karaf Decanter to become the Karaf Apaches way of monitoring.

Starting with Decanter 2.3.0 there is already a Prometheus appender included and starting with Karaf Decanter 2.7.0 there is also a Grafana/Loki appender available.

This is available in the current OH snapshot and documented here:

The link to the Grafana dashboard is broken due to an issue with the automatic documentation site creation but its available here:
https://raw.githubusercontent.com/openhab/openhab-addons/main/bundles/org.openhab.io.metrics/doc/dashboard.json