victron_mqtt_exporter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
marcel cb7c2c63fb Typo 2 years ago
conf Eerste versie 2 years ago
exampleconf Eerste versie 2 years ago
tests Eerste versie 2 years ago
utils Eerste versie 2 years ago
CHANGELOG.md Eerste versie 2 years ago
LICENSE Initial commit 2 years ago
README.md Typo 2 years ago
requirements-dev.txt Eerste versie 2 years ago
requirements-frozen.txt Eerste versie 2 years ago
requirements.txt Eerste versie 2 years ago
version.py Eerste versie 2 years ago
victron_mqtt_exporter.py Eerste versie 2 years ago

README.md

Prometheus exporter for Victron MQTT devices

A purposely build Prometheus exporter for Victron Energy Cerbo GX MQTT devices.

(C) 2022 M. Konstapel https://meezenest.nl/mees

Based on the General purpose Prometheus exporter for MQTT from Frederic Hemberger. (https://github.com/fhemberger/mqtt_exporter)

Subscribes to one or more MQTT topics, and lets you configure prometheus metrics based on pattern matching.

Features

  • Converts JSON string from Victron MQTT device topics to value readable by Prometheus.
  • Sends keepalive signal to Victron Energy Cerbo GX MQTT device (every 30 seconds).
  • Supported Metrics:
    • standard metrics
      • Gauge, Counter, Histogram, Summary
    • additional
      • Counter (Absolute):
        • Same as Counter, but working with absolute numbers received from MQTT. Which is far more common, than sending the diff in each publish.
        • e.g. a network counter or a rain sensor
      • Enum:
        • is a metric type not so common, details can be found in the OpenMetrics docs and Python client code.
        • Allows to track as state by a know set of strings describing the state, e.g. on/off or high/medium/low
        • Common sources would be a light switch oder a door lock.
  • Comprehensive rewriting for topic, value/payload and labels
    • similar to prometheus label rewrites
    • regex allows almost every conversion
    • e.g. to
      • remove units or other strings from payload
      • convert topic hierarchy into labels
      • normalize labels
    • check example configs ./exampleconf and the configs in ./test/test_data/

Usage

  • Create a folder to hold the config (default: conf/)
  • Add metric config(s) in YAML format to the folder. Files are combined and read as a single config. (See exampleconf/metric_example.yaml for details)
  • Install dependencies with pip3 install -r requirements-frozen.txt
  • Run ./victron_mqtt_exporter.py

Python dependencies

  • paho-mqtt
  • prometheus-client
  • PyYAML
  • yamlreader

TODO

  • Add persistence of metrics on restart
  • forget/age out metrics receiving no updates anymore