MQTT to influx - How to translate topics into fields

Hi,

I get stuck in translating mqtt topics to fields wit telegraf.
Here I have a example of MQTT topics that I want to translate into corresponding fields

MQTT Topics to capture:
t5s/pac/power/all
t5s/pac/power/L1
t5s/pac/power/L2
t5s/pac/power/L3

and also the same on t5s/pacws/power/+

MQTT subscribtion for this should be:
t5s/+/power/+

Tamplate pattern:
samplrate.measurement.field.field

(samplerate should be a tag set, tag_key=samplerate tag_value=t5s. Later I want to use this information to select the correct RP)

At the moment I can write some Data into influxdb, but telegraf uses “mqtt_consumer” as measurement and the whole topic as field.
I used data_format = “value” and data_type = “float” to convert the value, that worked just fine.
I thought using “templates” wous as easy as converting the value, but it has no effect. Reading the docs again I recognized that templates works only on telegraf metrics (dot delimited).
So I get stuck at this stage.
Can someone tell me if this conversion of the topic is possible in anyway with telegraf? or do i need an extra script to do this?

Hello @dkeipp,
Welcome!
Perhaps a look at # topic_tag = "topic" option will be useful to you.


Maybe this merged PR?

Thank you. Please let me know if that helps.