Oh, wow I’m very sorry I didn’t reply in time, somehow I didn’t get or notice the forum mail notifications
Thanks @ricadelic for the detailed instructions. Actually it should be no problem to place all the .jar files into the addons folder at the same time or at a random order. @mdnx the link https://github.com/KuguHome/openhab-prometheus-metrics/releases/ as @ricadelic posted it is the right place to look. The bundle is currently running in several field systems for us in beta state, development is somewhat paused but we are very interested in feedback!
@imaginator I am not aware of a similar approach for a direct item Prometheus exporter.From our point of view, the InfluxDB or any other persistence plugin would be the “correct” way to get the item values (going MQTT->Prometheus seems one step too much for me). We instead wanted to get values/metrics, which were (until now) hidden. Also, to our mind, Prometheus is more of a health metrics monitoring tool and less of a general value scraper. But you can certainly use it that way. It also shouldn’t be too much of a problem, to write an “Exposable” along the lines of https://github.com/KuguHome/openhab-prometheus-metrics/blob/master/com.kuguhome.openhab.prometheusmetrics/src/main/java/com/kuguhome/openhab/prometheusmetrics/exposable/OpenHABThingStateMetric.java which queries the item registry instead of the thing registry and outputs their values.
If it would be “switchable” within the bundle, we could include it, if you do a PR on GitHub.
I haven’t set this this up myself yet, but my understand is that Prometheus users Grafana as the display. So there shouldn’t be anything stopping you from adding graphs of stuff saved to InfluxDB through Persistence to the same Graphana dashboard.
My thinking on Prometheus is less about the graphing and more about the Prometheus query functions. I’d love to be able to detect water leaks by looking for sustained low values. Or predict energy consumption for the rest of the month. Or hook into the Prometheus alert manager … Or…
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 !
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?
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):
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
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).
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.