Parsing message, topics, and tags from mqtt

hi still new into telegraf config, so i want to make the “_” in this topics into however i put it in mqtt

sensor/lokasi/_/value

example:

sensor/lokasi/3 meter/value
sensor/lokasi/6 meter/value
sensor/lokasi/10 meter/value

i try with this configuration it didn’t do what i wanted to do

[[inputs.mqtt_consumer]]
  servers = ["mqtt://192.168.1.6:1883"]
  topics = [
  "sensor/lokasi/+/#",
  "sensor/lokasi/+/+",
  "sensor/+/+/+"
  ]
  qos = 1
  connection_timeout = "600s"
  max_undelivered_messages = 1000
  persistent_session = true
  client_id = "telegraf_cf820687"
  username = "Rahman"
  password = "<credential>"
  data_format = "value"
  data_type = "float"
[[inputs.mqtt_consumer.topic_parsing]]
    topic = "sensor/lokasi/+/+"
    measurement = "measurement/_/_/_"
    tags = "_/lokasi/_/_"
    fields = "_/_/_/ppm"

i try testing it by sent payloads with mqtt explorer but the configuration only sent this topic into data base

sensor/lokasi/kedalaman/value

the rest of topics like the examples above only appeared in mqtt explorer and in the telegraf log it seems like it ignored the message. what can i do to change the config so it become examples above and in influx is like the example below?

Hello @sin_356,
Can you please try:

[[inputs.mqtt_consumer]]
  servers = ["mqtt://192.168.1.6:1883"]
  topics = [
    "sensor/lokasi/+/#",
  ]
  qos = 1
  connection_timeout = "600s"
  max_undelivered_messages = 1000
  persistent_session = true
  client_id = "telegraf_cf820687"
  username = "Rahman"
  password = "<credential>"
  data_format = "value"
  data_type = "float"

[[inputs.mqtt_consumer.topic_parsing]]
    topic = "sensor/lokasi/+/value"
    measurement = "measurement"
    tags = "distance=lokasi/_"
    fields = "value=ppm"

Just make sure the topics you publish from your MQTT publisher match the pattern sensor/lokasi/{distance}/value, where {distance} can be 3 meter, 6 meter, etc. Also, ensure that the values published to these topics are compatible with the float data type specified in your Telegraf configuration.