Hi. I’m trying to get the data from Shelly devices to Influx using the telegraf and mosquitto MQTT broker, but still without success. The problem is, that in the data, there are subtopics where are different value types(float, int, string) as can be seen on pic from MQTT Explorer. Thanks for any help.
here’s the telegraf.conf
servers = ["tcp://127.0.0.1:1883"]
username = "********"
password = "********"
## Topics that will be subscribed to.
topics = [
"shellies/shellyplug-s-7AEC17/#",
]
[[inputs.mqtt_consumer.topic_parsing]]
topic = "shellies/shellyplug-s-7AEC17/relay/0"
measurement = "measurement/_/_/_"
fields = "_/_/_/value"
[inputs.mqtt_consumer.topic_parsing.types]
value = "string"
data_format = "value"
data_type = "float"
and error I get
2023-10-11T20:57:56Z I! Loading config: /etc/telegraf/telegraf.conf
2023-10-11T20:57:56Z I! Starting Telegraf 1.28.2 brought to you by InfluxData the makers of InfluxDB
2023-10-11T20:57:56Z I! Available plugins: 240 inputs, 9 aggregators, 29 processors, 24 parsers, 59 outputs, 5 secret-stores
2023-10-11T20:57:56Z I! Loaded inputs: mqtt_consumer
2023-10-11T20:57:56Z I! Loaded aggregators:
2023-10-11T20:57:56Z I! Loaded processors:
2023-10-11T20:57:56Z I! Loaded secretstores:
2023-10-11T20:57:56Z W! Outputs are not used in testing mode!
2023-10-11T20:57:56Z I! Tags enabled: host=Monitoring
2023-10-11T20:57:56Z I! [inputs.mqtt_consumer] Connected [tcp://127.0.0.1:1883]
2023-10-11T20:58:03Z E! [inputs.mqtt_consumer] Error in plugin: metric parse error: expected tag at 1:6: "74316"
2023-10-11T20:58:17Z E! [inputs.mqtt_consumer] Error in plugin: metric parse error: expected tag at 1:6: "24.41"
2023-10-11T20:58:17Z E! [inputs.mqtt_consumer] Error in plugin: metric parse error: expected tag at 1:6: "74316"
2023-10-11T20:58:17Z E! [inputs.mqtt_consumer] Error in plugin: metric parse error: expected tag at 1:3: "on"
2023-10-11T20:58:17Z E! [inputs.mqtt_consumer] Error in plugin: metric parse error: expected tag at 1:6: "29.18"
2023-10-11T20:58:17Z E! [inputs.mqtt_consumer] Error in plugin: metric parse error: expected tag at 1:6: "84.52"
2023-10-11T20:58:17Z E! [inputs.mqtt_consumer] Error in plugin: metric parse error: expected tag at 1:2: "0"