[metrics] Fix configuration PID and add file based configuration example (#11280)
Fixes #11279 Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
parent
b2d89d8c7f
commit
36b6b5b8c8
|
@ -1,6 +1,6 @@
|
|||
# Metrics service
|
||||
|
||||
The metrics service provides
|
||||
The metrics service provides:
|
||||
|
||||
* an additional REST endpoint to retrieve openHAB core metrics from. This can be used as scrape target for pull-based monitoring systems like [Prometheus](https://prometheus.io/).
|
||||
* optionally configurable services to export openHAB core metrics to push-based monitoring systems like [InfluxDB](https://www.influxdata.com/).
|
||||
|
@ -90,6 +90,23 @@ You can monitor the JMX metrics using a tool like [JConsole](https://docs.oracle
|
|||
When the JMX exporter is enabled, the metrics will be available under the "metrics" MBean.
|
||||
JConsole and VisualVM will only be able to connect using JMX when openHAB is started in debug mode (use `start_debug.sh` or `start_debug.bat`).
|
||||
|
||||
## Configuration file example
|
||||
|
||||
The example below shows how to configure the Metrics service using a file.
|
||||
|
||||
metrics.cfg:
|
||||
|
||||
```java
|
||||
influxMetricsEnabled=true
|
||||
influxURL=https://influxdb
|
||||
influxDB=metrics
|
||||
influxUsername=openhab
|
||||
influxPassword=77QjHkoWZEdbvXe9FWsJ
|
||||
influxUpdateIntervalInSeconds=60
|
||||
|
||||
jmxMetricsEnabled=false
|
||||
```
|
||||
|
||||
## Additional metric formats
|
||||
|
||||
The metrics service was implemented using [Micrometer](https://micrometer.io), which supports a number of [monitoring systems](https://micrometer.io/docs)
|
||||
|
@ -98,7 +115,8 @@ It should be possible to add any of these, especially the ones using a pull mech
|
|||
## Grafana
|
||||
|
||||
You can now visualize the results in Grafana. Micrometer provides a public [Grafana dashboard here](https://grafana.com/grafana/dashboards/4701).
|
||||
I adapted it a little bit to include the openHAB metrics. You can download it here [Dashboard](doc/dashboard.json).
|
||||
I adapted it a little bit to include the openHAB metrics.
|
||||
You can download it here [Dashboard](doc/dashboard.json).
|
||||
This has been tested with Prometheus - for other monitoring systems adaptions to the dashboard might be necessary.
|
||||
|
||||
Here are some screenshots:
|
||||
|
|
|
@ -56,7 +56,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||
*
|
||||
* @author Robert Bach - Initial contribution
|
||||
*/
|
||||
@Component(immediate = true, service = MetricsRestController.class)
|
||||
@Component(configurationPid = "org.openhab.metrics", immediate = true, service = MetricsRestController.class)
|
||||
@JaxrsResource
|
||||
@JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + "=" + RESTConstants.JAX_RS_NAME + ")")
|
||||
@Path(MetricsRestController.PATH_METRICS)
|
||||
|
|
Loading…
Reference in New Issue