[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'
services:
 alertmanager:
    restart: always
    container_name: alertmanager
    hostname: alertmanager
    image: prom/alertmanager
    volumes:
      - ./alertmanager.conf:/etc/alertmanager/alertmanager.conf
    command:
      - '--config.file=/etc/alertmanager/alertmanager.conf'
    ports:
      - 9093:9093

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

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

volumes:
  prometheus_data: {}

Then edit /etc/prometheus/prometheus.yml

scrape_configs:
  - job_name: 'openhab'
    scrape_interval: 1m
    scheme: http
    metrics_path: /rest/metrics/prometheus
    static_configs:
    - 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