Topic Parsing variable length topics

Hi, anyone know if it’s possible to use topic parsing on topics that are variable length?
For example I’m monitoring topics “a/#”, and one topic is “a/b/c” and another topic is “a/b/c/d”. I would like to do something like

  topic = "a/#"
  tags = "_/b_tag/c_tag/d_tag"

And if ‘d’ field is not present it still tags the event with ‘b_tag’ and ‘c_tag’.
When I try this I get a message Error running agent: could not initialize input inputs.mqtt_consumer: config error topic parsing: tags length does not equal topic length.

Try this config:

  # ... main plugin configuration here ...
    topic = "a/+/+/+"
    tags = "_/b_tag/c_tag/d_tag"
    topic = "a/+/+"
    tags = "_/b_tag/c_tag"

Thanks @Franky1, that works :+1:
A bit of a subjective question but do you know if it adds much overhead? It looks like it has to parse the topic twice for each event.