Hi
I’ve setup mosquitto, influxdb2, telegraf. mqtt data is published by tasmota devices as well as shelly devices.
I already fixed and understand some things, but I need some help understand some other things
I specified a a topic in my telegraf.conf. Only these values are read. But when I explore Data in the influxdb webinterface, I still see some (not all) other topics which are present in the mqtt broker, but without fields or measurements. I dont know if I have a wrong understanding of mqtt, but I thought, only the explicitly subscriped topics should show up?
I have the following json published to mosquitto:
Summary
{"Time":"2022-08-05T10:39:43","ENERGY":{"TotalStartTime":"2020-11-02T11:03:53","Total":54.687,"Yesterday":0.000,"Today":0.000,"Period": 0,"Power": 0,"ApparentPower": 0,"ReactivePower": 0,"Factor":0.00,"Voltage":221,"Current":0.000}}
The first “Time” does not show up as measurements, only the data in the ENERGY array.
In this array Telegraf did complain about the TotalStartTime with
Error in plugin: metric parse error: expected tag at 1:79:
I added
json_string_fields = [ "TotalStartTime" ]
to my telegraf.conf to cure this error.
My question is now: how can I get telegraf to read the first “Time”. It seems that it is completely ignored, because I assume otherwise telegraf would also have complained about the format? I suspect I have to do some conversion, as this is interpreted as a string?
What is happening with TotalStartTime after I added is to json_string_fields? Is it compeltely ignored now (which is fine, I just want to understand)?
My relevant telegraf.conf:
Summary
`[[inputs.mqtt_consumer]]
servers = [“tcp://mqqtbroker:1883”]
topics = [
“tele/rooms/+/SENSOR/#”
]
data_format = “json”
json_string_fields = [ “TotalStartTime” ]
client_id = “telegrafmqtt”
- Last question: I have the following structure in mqtt (picture is from mqtt explorer). The output is from shelly 2.5 devices.
I want to read the temperature. But If add the the topic to telegraf.conf I only get a lot of the following errors about almost all data. I also dont see data in mqtt.out (which I added to debug it).
Error in plugin: metric parse error: expected tag at 1:4:
Also no data is written to influxdb. I suspect because this is no valid JSON structure, that everything is interpreted as a string?
How can I read the values?
Thank you very much in advance, any help is much appreciated!