Hello everyone,
Please bear with me as I’m still new to Telegraf and figuring things out!
I’m working on an IoT system where each controller sends a binary-encoded MQTT message on a specific topic (temperature, humidity, pressure, etc.). Each message contains:
- The controller ID (8 bytes)
- 8 bytes of omitted data
- A 4-byte float representing the sensor value
I’m using Telegraf with the mqtt_consumer input plugin and the binary parser to extract this data and write it to InfluxDB. My Telegraf conf file looks like this:
[[inputs.mqtt_consumer]]
servers = ["tcp://myip"]
topics = [
"dioxygen",
"humidity",
"luminosity",
"pressure",
"temperature"
]
qos = 1
connection_timeout = "30s"
## binary_encoding
data_format = "binary"
binary_encoding = "none"
endianness = "le"
[[inputs.mqtt_consumer.binary]]
entries = [
{name = "controller_id", type = "int32", bits = 64, assignment = "tag"},
{bits = 64, omit = true},
{name = "value", type = "float32"}
]
The issue is that each topic is parsed independently and generates its own measurement with its own timestamp — even when multiple messages arrive at the exact same time. This results in timestamp redundancy and prevents me from having a single row with multiple fields per timestamp.
What I’d like is a way to have:
- A single timestamped row
- The sensor type & value as a key=value (tag) in Line protocol/2 columns in Influx
Can this kind of structure be achieved purely through the binary parser in Telegraf? Or is there a better approach to handle this cleanly within Telegraf without restructuring the MQTT payload format?
Thanks in advance!