I finally got it up & running As it was kind of a challenge, I’m posting the complete instruction here:
To get this cool dashboard in Grafana you need to:
-
Have a working Prometheus setup. (See https://prometheus.io/docs/prometheus/latest/getting_started/).
-
Have a working Grafana setup. (See InfluxDB+Grafana persistence and graphing).
-
Download http://central.maven.org/maven2/io/prometheus/simpleclient/0.4.0/simpleclient-0.4.0.jar and place it in the addons directory. Monitor the Openhab log file and wait until the jar has successfully registered in Openhab.
2018-12-15 03:15:44.636 [INFO ] [org.apache.felix.fileinstall ] - Installing bundle io.prometheus.simpleclient / 0.4.0
2018-12-15 03:15:44.881 [INFO ] [org.apache.felix.fileinstall ] - Started bundle: file:/usr/share/openhab2/addons/simpleclient-0.4.0.jar
- Download http://central.maven.org/maven2/io/prometheus/simpleclient_common/0.4.0/simpleclient_common-0.4.0.jar and place it in the addons directory. Monitor the Openhab log file and wait until the jar has successfully registered in Openhab.
2018-12-15 03:16:14.901 [INFO ] [org.apache.felix.fileinstall ] - Installing bundle io.prometheus.simpleclient_common / 0.4.0
2018-12-15 03:16:15.296 [INFO ] [org.apache.felix.fileinstall ] - Started bundle: file:/usr/share/openhab2/addons/simpleclient_common-0.4.0.jar
- Download http://repo1.maven.org/maven2/io/prometheus/simpleclient_hotspot/0.4.0/simpleclient_hotspot-0.4.0.jar and place it in the addons directory. Monitor the Openhab log file and wait until the jar has successfully registered in Openhab.
2018-12-15 03:17:56.501 [INFO ] [org.apache.felix.fileinstall ] - Installing bundle io.prometheus.simpleclient_hotspot / 0.4.0
2018-12-15 03:17:56.613 [INFO ] [org.apache.felix.fileinstall ] - Started bundle: file:/usr/share/openhab2/addons/simpleclient_hotspot-0.4.0.jar
- Download the latest jar from https://github.com/KuguHome/openhab-prometheus-metrics/releases/ and place it in the addons directory. Monitor the Openhab log file and wait until the jar has successfully registered in Openhab.
2018-12-15 03:18:27.292 [INFO ] [vice.internal.HttpServiceFactoryImpl] - Binding bundle: [com.kuguhome.openhab.prometheusmetrics_2.4.0.201808140810 [312]] to http service
2018-12-15 03:18:27.402 [INFO ] [rg.ops4j.pax.web.utils.ClassPathUtil] - Ignoring bundle scan for /META-INF/services javax.servlet.ServletContainerInitializer.
2018-12-15 03:18:27.407 [INFO ] [ce.jetty.internal.HttpServiceContext] - registering context DefaultHttpContext [bundle=com.kuguhome.openhab.prometheusmetrics_2.4.0.201808140810 [312], contextID=default], with context-name:
2018-12-15 03:18:27.419 [INFO ] [.jetty.server.handler.ContextHandler] - Started HttpServiceContext{httpContext=DefaultHttpContext [bundle=com.kuguhome.openhab.prometheusmetrics_2.4.0.201808140810 [312], contextID=default]}
2018-12-15 03:18:27.481 [INFO ] [org.apache.felix.fileinstall ] - Started bundle: file:/usr/share/openhab2/addons/com.kuguhome.openhab.prometheusmetrics-2.4.0-SNAPSHOT.jar
-
If loading of the bindings went ok, you should be able to open http://openhabserver:8080/rest/metrics/prometheus and you will see a page like https://github.com/KuguHome/openhab-prometheus-metrics/wiki/Example-scrape . If an error occured in the previous steps, you’ll see a 404 error.
-
Now add a job in Prometheus. I installed it today so I’m by no means an expert. In prometheus.yaml, add the following under scrape_configs:
- job_name: 'openhab_metrics'
scrape_interval: 10s
scheme: http
metrics_path: /rest/metrics/prometheus
static_configs:
- targets:
- 'openhabserver:8080'
- After a Prometheus service restart, you can browse to http://prometheusserver:9090/targets, and the scraper is up:
## [openhab_metrics (1/1 up)](http://prometheusserver:9090/targets#job-openhab_metrics)
|Endpoint|State|Labels|Last Scrape|Scrape Duration|Error
|http://openhabserver:8080/rest/metrics/prometheus|UP|instance="openhabserver:8080" job="openhab_metrics"|8.967s ago|78.19ms|
-
Now download the Grafana dashboard from https://github.com/KuguHome/openhab-prometheus-metrics/wiki/Grafana-source and replace the data source “kugu-prometheus” to the correct data source. For me, it was just “Prometheus”.
-
Import the dashboard in Grafana. Grafana shouldn’t complain about missing data sources.
I’m really impressed by the amount of insight you get when using this dashboard. Thanks, @friesenkiwi !