# Rabbitmq output plugin : dynamic values on headers not working

**URL:** <https://discuss.elastic.co/t/rabbitmq-output-plugin-dynamic-values-on-headers-not-working/260475>\
**Category:** Logstash\
**Created:** [January 7, 2021, 5:32pm UTC](https://discuss.elastic.co/t/rabbitmq-output-plugin-dynamic-values-on-headers-not-working/260475 "2021-01-07T17:32:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarineW29](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marinew29/32/78185_2.png) [@MarineW29](https://discuss.elastic.co/u/MarineW29)\
**Post date:** [January 7, 2021, 5:32pm UTC](https://discuss.elastic.co/t/rabbitmq-output-plugin-dynamic-values-on-headers-not-working/260475/1 "2021-01-07T17:32:11Z")

</div>

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](https://github.com/logstash-plugins/logstash-integration-rabbitmq/issues/27#issuecomment-628031568)

The version I use seems to be OK 7.1.1 :

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

```

My configuration :

```auto
    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 :

```auto
    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 !

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 7, 2021, 6:04pm UTC](https://discuss.elastic.co/t/rabbitmq-output-plugin-dynamic-values-on-headers-not-working/260475/2 "2021-01-07T18:04:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MarineW29](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marinew29/32/78185_2.png) [@MarineW29](https://discuss.elastic.co/u/MarineW29)\
**Post date:** [January 7, 2021, 6:16pm UTC](https://discuss.elastic.co/t/rabbitmq-output-plugin-dynamic-values-on-headers-not-working/260475/3 "2021-01-07T18:16:14Z")

</div>

Thanks Badger.  
It's surprising that [this issue](https://github.com/logstash-plugins/logstash-integration-rabbitmq/issues/27#issuecomment-628031568) was closed by @yaauie then...

---

<div class="post-metadata">

**Author:** ![MarineW29](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marinew29/32/78185_2.png) [@MarineW29](https://discuss.elastic.co/u/MarineW29)\
**Post date:** [January 8, 2021, 7:56am UTC](https://discuss.elastic.co/t/rabbitmq-output-plugin-dynamic-values-on-headers-not-working/260475/4 "2021-01-08T07:56:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 8, 2021, 3:17pm UTC](https://discuss.elastic.co/t/rabbitmq-output-plugin-dynamic-values-on-headers-not-working/260475/5 "2021-01-08T15:17:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MarineW29](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marinew29/32/78185_2.png) [@MarineW29](https://discuss.elastic.co/u/MarineW29)\
**Post date:** [January 8, 2021, 4:25pm UTC](https://discuss.elastic.co/t/rabbitmq-output-plugin-dynamic-values-on-headers-not-working/260475/6 "2021-01-08T16:25:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 5, 2021, 4:25pm UTC](https://discuss.elastic.co/t/rabbitmq-output-plugin-dynamic-values-on-headers-not-working/260475/7 "2021-02-05T16:25:19Z")

</div>

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