Help with Telegram MQTT Parser

Hello ,
i am using zigbee2mqtt and I would like to parse the data from MQTT to InfluxDB.
Till now i am using this configuration and all is working as intended , however now i want to use Device name as a tag and configure:
[[inputs.mqtt_consumer.topic_parsing]]
topic = “zigbee2mqtt/+/#”
measurement = “measurement/ _ / "
tags = "
/Device/ _”
When i added the topic parsing , Telegraf start generating errors as :
2022-10-06T12:54:25Z E! [inputs.mqtt_consumer] Error in plugin: metric parse error: expected tag at 1:33: “{"battery":77.5,"humidity":39.58,"linkquality":142,"temperature":24.41,"voltage":2900}”
It kinda try to look in the Json, instead of getting the tag from the Device name which is in the topic.

Any help will be really appreciated.


[[inputs.mqtt_consumer]]

servers = [“tcp://192.168.1.44:1883”]

topics = [

“zigbee2mqtt/BathTemp/#”,

“zigbee2mqtt/KitchenMotionSensor/#”,

“zigbee2mqtt/LightSLivingRoom/#”,

]

data_format = “json”

json_time_key = “”

json_string_fields = [“state”,“occupancy”]

Hello @Tihomir_Karagyozov,
Let me connect you with @Jay_Clifford our MQTT expert.

1 Like

Thank you .
I figure it out :wink:
I forgot to add topic when I defined the parser, now is working with this code

[[inputs.mqtt_consumer.topic_parsing]]
topic = “zigbee2mqtt/+”
measurement = “measurement/"
tags = "
/Device”