There is a better way to do that, use the bucket_tag option of the InflxDB2 output (docs here)
it allows you to specify the “routing” by using a tag value
Here is a sample using your current config
[[inputs.mqtt_consumer]]
servers = ["tcp://e_mqtt:1883"]
topics = [
"Y/Schlafzimmer/power/SENSOR",
]
data_format = "json"
[inputs.mqtt_consumer.tags]
destination = "Ybucket"
[[inputs.mqtt_consumer]]
servers = ["tcp://e_mqtt:1883"]
topics = [
"PowerMeter/001/power/SENSOR",
"PowerMeter/002/power/SENSOR",
]
data_format = "json"
[inputs.mqtt_consumer.tags]
destination = "Zbucket"
[[outputs.influxdb_v2]]
urls = ["http://e_influxdb:8086"]
token = "ULw91qCCOyBrVqwWyNdmy8ckzmJhjbrZMhgf57XmXp4elkFsf-atwpQ=="
organization = "my-org"
bucket_tag = "destination"
## If true, the bucket tag will not be added to the metric.
exclude_bucket_tag = true