Rabbitmq output plugin : dynamic values on headers not working

Hello,

I have a pipeline with elasticsearch input and rabbitmq output.
I would like to set dynamic values to headers in properties of the message published in RabbitMQ, but the field are not replaces with their values.

I saw the feature has been added in 7.1.0 version on RabbitMQ integration plugin : https://github.com/logstash-plugins/logstash-integration-rabbitmq/issues/27#issuecomment-628031568

The version I use seems to be OK 7.1.1 :

    bash-4.2$ logstash-plugin list --verbose
    (...)
    logstash-integration-rabbitmq (7.1.1)
     ├── logstash-input-rabbitmq
     └── logstash-output-rabbitmq

My configuration :

    output {
      rabbitmq {
        id => "mwx-rabbitmq-output"
        host =>"rabbitmq"
        port => "5672"
        user => "***"
        password => "***"
        ssl => "false"
        vhost => "/"
        durable => true 
        automatic_recovery => true
        persistent => true
        exchange => "sys-logstash-out"
        exchange_type => "topic"
        key => "app-%{[properties][app-id]}-default"
        # Fill the payload with "message" field :
        codec => plain { format => "%{[message]}" }
        message_properties => {
          "content_type" => "application/json"
          "priority" => 2
          "app_id" => "%{[properties][app-id]}"
          "headers" => {
            "test" => "%{[message]}"
          }
        }
      }
    }

The resulting message in RabbitMQ :

    Exchange          sys-logstash-out
    Routing Key	      app-app-test-MWX-default
    Redelivered       ●
    Properties	
       app_id:        app-test-MWX
       priority:      2
       delivery_mode: 2
       headers:	
          test:       %{[message]}
       content_type:  application/json
    Payload           Test header 1

As you can see :

  • "%{[message]}" exists and is well replaced in payload part.
  • the "app_id" property is also OK
  • but the "test" header is not OK

I have tested several syntax, with no success.
Can anyone help me please ?
Thanks !

Looking at the code, it appears to sprintf the top-level items in message_properties (such as app_id) but does not iterate over the items nested inside them.

Thanks Badger.
It's surprising that this issue was closed by @yaauie then...

Maybe I don't use the syntax expected by this feature ?
Or the feature wasn't really taken into account and we should open a new feature request ?
In that case, is there a workaround to use meanwhile ?
Thanks for any further advices.

I cannot think of a workaround. Opening a new issue seems reasonable.

Thanks again Badger.
I opened a new issue : https://github.com/logstash-plugins/logstash-integration-rabbitmq/issues/41

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.