A simple and straightforward script for exposing OpenHAB 2 items as Prometheus metrics. Note that the steps below have been based on a Raspberry PI 2 with Raspbian installed.
Typically you'd install this script on the same server that runs OpenHAB 2.
python3
and gunicorn3
packages. Make sure python3
is version 3.5 or higher
python3 --version
openhab2-exporter.py
in a directory of choice
/opt/openhab2-exporter
openhab2-exporter.service.template
as /etc/systemd/system/openhab2-exporter.service
99999
to a port of your choiceWorkingDirectory
property accordinglysystemctl start openhab2-exporter.service
You can check if everything's working correctly by opening http://servername:port
, where servername
is the
name or ip of the server that runs the script, and port
is the port you chose to run the service on. If all
went well you should see the raw metrics appear.
Also don't forget to add this location to your scrape targets in Prometheus!