# RabbitMQ input plugin: add\_field doesn't write @metadata

**URL:** <https://discuss.elastic.co/t/rabbitmq-input-plugin-add-field-doesnt-write-metadata/82152>\
**Category:** Logstash\
**Created:** [April 12, 2017, 11:53am UTC](https://discuss.elastic.co/t/rabbitmq-input-plugin-add-field-doesnt-write-metadata/82152 "2017-04-12T11:53:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gertvv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gertvv/32/17289_2.png) [@gertvv](https://discuss.elastic.co/u/gertvv)\
**Post date:** [April 12, 2017, 11:53am UTC](https://discuss.elastic.co/t/rabbitmq-input-plugin-add-field-doesnt-write-metadata/82152/1 "2017-04-12T11:53:51Z")

</div>

This is using logstash 5.2.0 and the version of the RabbitMQ plugin that comes with it.

```auto
input {
  rabbitmq {
    ...
    add_field => {
      "[@metadata][indexType]" => "myindex"
    }
}

output {
  elasticsearch {
    hosts => ["elasticsearch"]
    index => "%{[@metadata][indexType]}-%{+YYYY.MM.dd}"
  }
}

```

Results in errors due to [@metadata][indexType] not being set. But this workaround does work:

```auto
input {
  rabbitmq {
    ...
    add_field => {
      "indexType" => "myindex"
    }
}

filter {
  mutate {
    add_field => { "[@metadata][indexType]" => "%{indexType}" }
    remove_field => ["indexType"]
  }
}

...

```

Googling suggested to me that the prior syntax is expected to work, at least for the file plugin. Is this a bug?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 12, 2017, 1:13pm UTC](https://discuss.elastic.co/t/rabbitmq-input-plugin-add-field-doesnt-write-metadata/82152/2 "2017-04-12T13:13:12Z")

</div>

Don't you have `=>` after `add_field` in your input block?

---

<div class="post-metadata">

**Author:** ![gertvv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gertvv/32/17289_2.png) [@gertvv](https://discuss.elastic.co/u/gertvv)\
**Post date:** [April 16, 2017, 4:00pm UTC](https://discuss.elastic.co/t/rabbitmq-input-plugin-add-field-doesnt-write-metadata/82152/3 "2017-04-16T16:00:14Z")

</div>

No, I do, that's a copy/paste error on my part. I've edited the question.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 18, 2017, 5:25am UTC](https://discuss.elastic.co/t/rabbitmq-input-plugin-add-field-doesnt-write-metadata/82152/4 "2017-04-18T05:25:26Z")

</div>

I can confirm that this is a bug (a regression introduced in v5.0.0 of the plugin). I've filed this issue:

> <https://github.com/logstash-plugins/logstash-input-rabbitmq/issues/98>

---

<div class="post-metadata">

**Author:** ![gertvv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gertvv/32/17289_2.png) [@gertvv](https://discuss.elastic.co/u/gertvv)\
**Post date:** [April 18, 2017, 8:33am UTC](https://discuss.elastic.co/t/rabbitmq-input-plugin-add-field-doesnt-write-metadata/82152/5 "2017-04-18T08:33:13Z")

</div>

Excellent, thank you for the quick turnaround. Looking forward to this being fixed - I'll watch the GitHub issue.

---

<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:** [May 16, 2017, 8:45am UTC](https://discuss.elastic.co/t/rabbitmq-input-plugin-add-field-doesnt-write-metadata/82152/6 "2017-05-16T08:45:48Z")

</div>

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