Inputs.mqtt_consumer.topic_parsing

Hi,

I got this structure in my MQTT broker:

FH/SB/101/Flow (float
FH/SB/101/M3h (float)
FH/SB/101/Total (int)
FH/SB/101/kWh (float)
FH/SB/101/Name (string)

FH is also the name of my bucket. I want to have SB and 101 as tags and Flow, kWh etc. as measurements. How can I parse this ?

My last atempt is here:

[[inputs.mqtt_consumer]]
   servers = ["tcp://10.253.24.74:1883"]

   topics = ["FH/#"]
   data_format = "influx"
   data_type = "float"

   [[inputs.mqtt_consumer.topic_parsing]]
      data_format = "value"
      data_type = "float"
      topic = "FH/+/+/+"
      measurement = "_/_/_/measurement"
      tags = "_/area/unit/_"
      fields = "_/_/_/_"

thanks.

@Fogh topic_parsing allows to parse the topic string, it is not meant for specifying individual parsers per topic! So you can use

[[inputs.mqtt_consumer]]
   servers = ["tcp://10.253.24.74:1883"]

   topics = ["FH/#"]
   data_format = "value"
   data_type = "auto_float"

   [[inputs.mqtt_consumer.topic_parsing]]
      topic = "FH/+/+/+"
      measurement = "_/_/_/measurement"
      tags = "_/area/unit/_"
      fields = "_/_/_/_"

here. This will try to parse the data to float and falls back to string if that fails.

Alternatively, you can use data_type = "string" and use the converter processor to map the fields to the correct type…