[OH3] Metrics Service and InfluxDB

  • Platform information:
    • openHAB version: 3.2
    • DB version: InfluxDB 1.8

I installed the Metrics Service and like to use it with InfluxDB.
The required configuration parameters are all added via the GUI under Settings → Additional Services → Metrics Services.

I use the dashboard template which is provided in the Add-ons documentation. I’m aware that I need to change the datasource from Prometheus to InfluxDB.
But in the InfluxDB there is not a single entry available for any metrics. Is there anything else required to set it up?

If I query the DB with show measurements I just see the defined values for my items, but nothing concerning the metrics which should be provided by the metrics service.

Has anyone implemented the InfluxDB based Metrics Service successfully?

You need to install Prometheus. (see documentation for config) The metrics are provided via Prometheus and stored in InfluxDB
I run Prometheus in a docker container and works flawlessly

cat prometheus/docker-compose.yml

version: '3'
    restart: always
    container_name: alertmanager
    hostname: alertmanager
    image: prom/alertmanager
      - ./alertmanager.conf:/etc/alertmanager/alertmanager.conf
      - '--config.file=/etc/alertmanager/alertmanager.conf'
      - 9093:9093

    restart: always
    image: prom/node-exporter
      - '9100:9100'

    restart: always
    container_name: prometheus
    hostname: prometheus
    image: prom/prometheus
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
      - ./alert_rules.yml:/etc/prometheus/alert_rules.yml
      - prometheus_data:/prometheus
      - '--config.file=/etc/prometheus/prometheus.yml'
      - 9090:9090
      - alertmanager:alertmanager

  prometheus_data: {}

Then edit /etc/prometheus/prometheus.yml

  - job_name: 'openhab'
    scrape_interval: 1m
    scheme: http
    metrics_path: /rest/metrics/prometheus
    - targets:
      - ‘YOUR_OH3_IPADDRESS:8080'

I had the same issue with a freshly installed openHABian project version 3.2.0 based on debian bullseye.
I could help myself by copying a metrics configuration file into the conf/services folder. The structure of the file is described here: Metrics service - System Integrations | openHAB

Enabling the ‘influx metrics’ switch in the metrics settings in UI had no effect. I don’t have this issue with my openHABian 3.2.0 installation based on debian buster. However, this is an update not a fresh installation.

Installation of Prometheus is not needed if you are willing to adapt the Grafana template to influx sql syntax.

1 Like

You don’t need Prometheus, but it seems the setting in the gui does nothing (except give you false hope) You need to create the metrics.cfg (as showing in the docs) in /etc/openhab/services/ for the influx dump to be activated.

Mine’s working on Openhab 3.4