# Kafka output. How to set a key from message value?

**URL:** <https://discuss.elastic.co/t/kafka-output-how-to-set-a-key-from-message-value/353185>\
**Category:** Logstash\
**Created:** [February 13, 2024, 3:06pm UTC](https://discuss.elastic.co/t/kafka-output-how-to-set-a-key-from-message-value/353185 "2024-02-13T15:06:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pooort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pooort/32/131232_2.png) [@Pooort](https://discuss.elastic.co/u/Pooort)\
**Post date:** [February 13, 2024, 3:06pm UTC](https://discuss.elastic.co/t/kafka-output-how-to-set-a-key-from-message-value/353185/1 "2024-02-13T15:06:22Z")

</div>

I'm using logstash to ingest data from Redshift table and put into Kafka.  
It works great. But how to use input field as Kafka's key?

---

<div class="post-metadata">

**Author:** ![Artem\_Belousov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/artem_belousov/32/122198_2.png) [@Artem\_Belousov](https://discuss.elastic.co/u/Artem_Belousov)\
**Post date:** [February 27, 2024, 10:14am UTC](https://discuss.elastic.co/t/kafka-output-how-to-set-a-key-from-message-value/353185/2 "2024-02-27T10:14:40Z")

</div>

It seems like it doesnt work. Tried to use message\_key, but no way

---

<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 26, 2024, 10:15am UTC](https://discuss.elastic.co/t/kafka-output-how-to-set-a-key-from-message-value/353185/3 "2024-03-26T10:15:00Z")

</div>

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