# Configuring message\_key kafka output plugin

**URL:** <https://discuss.elastic.co/t/configuring-message-key-kafka-output-plugin/121421>\
**Category:** Logstash\
**Created:** [February 26, 2018, 12:56am UTC](https://discuss.elastic.co/t/configuring-message-key-kafka-output-plugin/121421 "2018-02-26T00:56:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maher\_Ben\_Taleb\_Ali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maher_ben_taleb_ali/32/26774_2.png) [@Maher\_Ben\_Taleb\_Ali](https://discuss.elastic.co/u/Maher_Ben_Taleb_Ali)\
**Post date:** [February 26, 2018, 12:56am UTC](https://discuss.elastic.co/t/configuring-message-key-kafka-output-plugin/121421/1 "2018-02-26T00:56:15Z")

</div>

Hi,  
I am trying to send data from elasticsearch into Kafka.

```
input {
      elasticsearch {
        hosts => "localhost"
        index => "articles"
      }
    }
    output {
      kafka {
        topic_id => "articles"
      }
    }

```

what I receive In Kafka is something like this "host %{message}".  
when I create a message field I receive a the text within the message's field.  
kafka is expecting a message\_key, but the input json doesn't contain a root field so I can set it.

---

<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:** [February 27, 2018, 8:09am UTC](https://discuss.elastic.co/t/configuring-message-key-kafka-output-plugin/121421/2 "2018-02-27T08:09:36Z")

</div>

Sounds like you'll want to set `codec => json` for the kafka output.

---

<div class="post-metadata">

**Author:** ![Maher\_Ben\_Taleb\_Ali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maher_ben_taleb_ali/32/26774_2.png) [@Maher\_Ben\_Taleb\_Ali](https://discuss.elastic.co/u/Maher_Ben_Taleb_Ali)\
**Post date:** [February 27, 2018, 4:44pm UTC](https://discuss.elastic.co/t/configuring-message-key-kafka-output-plugin/121421/3 "2018-02-27T16:44:36Z")

</div>

yup thanks, you saved the day

---

<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:** [March 27, 2018, 4:44pm UTC](https://discuss.elastic.co/t/configuring-message-key-kafka-output-plugin/121421/4 "2018-03-27T16:44:58Z")

</div>

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