Open RichieB2B opened 2 years ago
Happy to take a PR. Should either be an option or just published additionally.
I would if I had any experience with writing Go which I unfortunately don't. The required code is quite similar to allDevicesHandler() in http.go which probably could be called from Run() in mqtt.go
I solved my need (getting mbmd data into prometheus) using this small script:
#!/bin/bash
while [ 1 ]; do
curl -s http://localhost:8080/api/last/ORNO3p1.1 | mosquitto_pub -t mbmd/orno3p1-1 -l
sleep 5
done
And this mqtt2prometheus config.yml
:
mqtt:
server: tcp://127.0.0.1:1883
topic_path: mbmd/orno3p1-1
qos: 0
cache:
timeout: 1h
metrics:
- prom_name: mbmd_power
mqtt_name: Power
help: power consumption in Watt
type: gauge
- prom_name: mbmd_usage
mqtt_name: Import
help: energy usage in kWh
type: counter
- prom_name: mbmd_currentL1
mqtt_name: CurrentL1
help: L1 current in Ampere
type: gauge
- prom_name: mbmd_currentL2
mqtt_name: CurrentL2
help: L2 current in Ampere
type: gauge
- prom_name: mbmd_currentL3
mqtt_name: CurrentL3
help: L3 current in Ampere
type: gauge
It would still be nice though to have mbmd
publish JSON data to MQTT.
mbmd
is really cool and almost exactly what I was looking for. Currently it is publishing each measurement in it's own MQTT topic like this:It would be great if
mbmd
has an option to publish all measurements in a JSON message in a single topic like this:This matches more with other uses of MQTT that I have seen. Also, it would mean tools like mqtt2prometheus would also work with the MQTT output.