Hello,
i’m trying to setup a mqtt consumer telegraf node. My situation is the same as #10712, for example:I have the following topics
ACME/controller0/v1/air-conditioner/temp (e.g. 23.59 - float )
ACME/controller0/v1/air-conditioner/rpm (e.g. 2000 - int )
ACME/controller0/v1/air-conditioner/mode (e.g. MANUAL - string)
I need to consume the mqtt data to an influxdb node. To do so i have written the following config:
[...]
[[inputs.mqtt_consumer]]
servers = ["tcp://acme.mqtt.org:8883"]
topics = [
"ACME/#",
]
data_format = "value"
data_type = "string"
[[inputs.mqtt_consumer.topic_parsing]]
topic = "ACME/+/+/+/temp"
measurement = "agency/_/_/_/_"
tags = "_/controller_id/controller_version/contoller_type/_"
fields = "_/_/_/_/temperature"
[inputs.mqtt_consumer.topic_parsing.types]
temperature = "float"
# Other topic parsers to differentiate the types, same as above but with a different type
[[inputs.mqtt_consumer.topic_parsing]]
topic = "ACME/+/+/+/rpm"
[ ... ]
I’ve got 2 problems:
- Standard mqtt_consumer LPs get generated even though the topic_parser is active, e.g.
mqtt_consumer,host=this-host,topic=ACME/controller0/v1/air-conditioner/temp value="23.59" 1651224634909093887
- The plugin is unable to convert from
string
to (e.g.)float
, giving
[inputs.mqtt_consumer] Error in plugin: unable to convert field 'temp' to type float: strconv.ParseFloat: parsing "temp": invalid syntax
What am i doing wrong? Is this the best-practice for dealing with multiple types of mqtt values?Thanks in advance