MQTT - parsing / topic problem

i am reading data from a microcontroller
home/room/workshop/temperature1 20.36
home/room/workshop/humidity 46.36
home/room/workshop/pressure 996.27
home/room/workshop/temperature2 16.94

i read in this data with telegraf
telegraf.conf

[[inputs.mqtt_consumer]]

topics = [
“home/+/+/+”,
]

data_format = “value”
data_type = “float”

and
[[inputs.mqtt_consumer.topic_parsing]]
topic = “home/+/+/+”
measurement = “measurement///"
tags = "
/location1/location2/field”
#fields = “//_/test”

## Value supported is int, float, unit

# [[inputs.mqtt_consumer.topic.types]]

key = float

[[processors.pivot]]
tag_key = “field”
value_key = “value”

output from the log file

home,location1=room,location2=workshop,topic=home/room/workshop/temperature2 temperature2=16.88 1678815798606918574

my problem is now, the issue of topic=… since this is also written to the database

A solution is to leave out the topic area [[inputs.mqtt_consumer.topic_parsing]], but then telegraf no longer starts.
2023-03-14T17:53:25Z E! [telegraf] Error running agent: could not initialize input inputs.mqtt_consumer: config error topic parsing: measurement length does not equal topic length
the database entry
Table: keys: [_start, _stop, _field, _measurement, location1, location2, topic]
_start:time _stop:time _field:string _measurement:string location1:string location2:string topic:string _time:time _value:float


2023-03-14T17:27:59.732326779Z 2023-03-14T17:57:59.732326779Z temperature1 home room workshop home/room/workshop/temperature1 2023-03-14T17:31:18.550720212Z 20.19

I don’t know how I don’t get this entry topic= transferred to the database
Tanks

Your topic parsing section is screwed… Every element there has to have the same (topic-length) number of elements e.g.

[[inputs.mqtt_consumer.topic_parsing]]
  topic = "home/+/+/+"
  measurement = "/measurement/_/_/_"
  tags = "/_/location1/location2/field"

Hi,
I don’t understand the hint.
My topic from controller is:
home/room/workshop/temperature1 23.02
home/room/workshop/humidity 37.63
home/room/workshop/pressure 1012.33
home/room/workshop/temperature2 19.06

I have four entries
home measurement
room location1
workshop location2
temperature1 field

[[inputs.mqtt_consumer.topic_parsing]]
topic = “home/+/+/+”
measurement = “measurement///"
tags = "
/location1/location2/field”
#fields = “//_/field”

The entry in the database is:
Table: keys: [_start, _stop, _field, _measurement, location1, location2, topic]
_start:time _stop:time _field:string _measurement:string location1:string location2:string topic:string _time:time _value:float


2023-03-15T13:15:07.861256140Z 2023-03-15T13:25:07.861256140Z temperature2 home room workshop home/room/workshop/temperature2 2023-03-15T13:24:48.356193692Z 19.31

It doesn’t look bad, but the topic entry shouldn’t be there.
I can’t get rid of this entry with telegraf.

I tested a little.
The configuration works fine, but the “topic” entry in the database doesn’t have to be.

[[inputs.mqtt_consumer.topic_parsing]]
topic = “home/+/+/+”
measurement = “measurement///"
tags = "
/location1/location2/field”
#fields = “//_/field”

[[processors.pivot]]
tag_key = “field”
value_key = “value”

It just takes up space.
If someone else has an idea, that would be nice, otherwise I’ll write a program.

2023-03-17T16:40:57.273213356Z 2023-03-17T16:50:57.273213356Z temperature2 home room workshop home/room/workshop/temperature2 2023-03-17T16:50:32.177384182Z 19.31

Note: the description “MQTT Consumer Telegraf Input Plugin” does not work

example

[[inputs.mqtt_consumer]]

topics = “/sensors/#”
[[inputs.mqtt_consumer.topic_parsing]]
measurement = “/measurement////
tags = “/_/site/version/device_name/field”
[[processors.pivot]]
tag_key = “field”
value_key = “value”

greetings

@Heinz the topic takes up exactly one time the byte size of the topic text for InfluxDB, but you can get rid of it using metric modifiers more specifically tagexclude.

Thanks for the info.
I wasn’t at home and will try it now.

Hello,
i have some problems with the syntax.
tagexclude = [“home”] doesn’t work that way
my solution is:
[[inputs.mqtt_consumer]]

Topics that will be subscribed to.

 topics = [
     "home/#"
 ]


data_format = “value”
data_type = “float”
topic_tag = “”

now the topic is no longer stored in the database.
_start:time _stop:time _field:string _measurement:string location1:string location2:string _time:time _value:float


2023-04-12T08:27:32.087611861Z temperature2 home room workshop 2023-04-12T08:28:11.393511938Z 10.69
2023-04-12T08:27:32.087611861Z temperature2 home room workshop 2023-04-12T08:29:11.396965350Z 10.75

I don’t know if it’s the best solution, but this is how it works

Well it would be tagexclude = ["topic"] as the tag is named topic