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 !