Hi All,
unfortunately I’m still a total newbie in the field of “logging MQTT messages to InfluxDB using Telegraf” and therefore could really benefit from some help with the configuration of the MQTT Consumer Input plugin. I’ve read quite a bit about it on the Internet, but I feel I’m still a long way from being able to use it safely.
Based on this article, I’m starting to understand how to generate tag set and field set for InfluxDB’s line protocol from the components of the topic and the fields of the JSON payload.
Let’s say: In my application I get MQTT telegrams with a topic:
my_smarthome/rooms/bedroom/sensors/sensor0x3E26A
and a JSON payload:
{
"timestamp": 1695409130000000000
"type": "BME280"
"last_calibration": "2022-12-12"
"temperature_degC": 22.35
"relative_humidity": 66.28
}
What would be a useful configuration file? Are there any matching examples to this application?
What is the minimum information that must be included?
(I guess: MQTT broker address, port, user name, password, list of subscribed topics, QoS, payload data format…topic-/payload-parsing statements…what else?)
How would you read the field “timestamp” (here practically already suitable for InfluxDB in ns since 1970-01-01) and use it as a timestamp for the LP instead of as a regular field (like a measured value)? None of the examples on the internet address this. There as timestamp for the LP always only the reception time of the MQTT telegram is used, that means the time is not obtained from the MQTT telegram.
What if the timestamp was included in the payload as an ISO8601 string and had to be converted first?
Any tips and links to easy to understand tutorials are greatly appreciated.
Many thanks!
Best,
conne914