I have a set of MQTT topics as follows:
powermonitor/SERIALID/sensor/power/state
powermonitor/SERIALID/sensor/current/state
powermonitor/SERIALID/sensor/frequency/state
powermonitor/SERIALID/sensor/power_factor/state
powermonitor/SERIALID/sensor/voltage/state
The data from these topics are all floats. They’re not contained within a JSON container, they’re just raw in the topic. The topics are updated at varying rates.
I have an MQTT consumer input connected to the broker with access to these topics.
[[inputs.mqtt_consumer]]
servers = ["tcp://127.0.0.1:1883"]
topics = [
"powermonitor/+/sensor/+/state"
]
qos = 1
persistent_session = true
client_id = "telegraf"
username = "USERNAME"
password = "PASSWORD"
data_format = "value"
data_type = "float"
[[inputs.mqtt_consumer.topic_parsing]]
topic = "powermonitor/+/sensor/+/state"
measurement = "measurement/_/_/_/_"
tags = "_/serial/_/_/_"
fields = "_/_/_/field/_"
[inputs.mqtt_consumer.topic_parsing.types]
field = "string"
I’m struggling to work out what I’m doing wrong, as despite fiddling around with all manner of different parameters, Telegraf doesn’t appear to pick up on any of the messages to the topics.
I’m sure I’ve missed something and it’ll be an easy fix, but I’m aiming for metrics as follows:
powermonitor,serial=SERIALID power=390.0 1657282270000000000
powermonitor,serial=SERIALID current=2.0 1657282270000000000
powermonitor,serial=SERIALID frequency=49.9 1657282270000000000
powermonitor,serial=SERIALID power_factor=0.8 1657282270000000000
powermonitor,serial=SERIALID voltage=233.3 1657282270000000000
I’ve been testing with an file output to stdout, and this MQTT_Consumer appears to do nothing at all. " are shown to load in the Telegraf logs, but only the other one produces metrics.
@Jay_Clifford if you (or anyone else) has any ideas it’d be greatly appreciated!
Thanks
PS, the data format is loosely based on the format from ESPHome, for if anyone is searching this in the future.