# Use kafka mesage key as index route

**URL:** <https://forum.opensearch.org/t/use-kafka-mesage-key-as-index-route/19321>\
**Category:** Data Prepper\
**Created:** [May 13, 2024, 1:55am UTC](https://forum.opensearch.org/t/use-kafka-mesage-key-as-index-route/19321 "2024-05-13T01:55:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbates5873](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@jbates5873](https://forum.opensearch.org/u/jbates5873)\
**Post date:** [May 13, 2024, 1:55am UTC](https://forum.opensearch.org/t/use-kafka-mesage-key-as-index-route/19321/1 "2024-05-13T01:55:55Z")

</div>

Hi All,

I am looking into using dataprepper to ship the logs from my Kafka instance into Opensearch.

However, as i have data collected from multiple inputs into a topic, i use the ‘Key’ field as an index router.

However, im not sure how to have data prepper read this key, and use it as the variable for routing to the correct index. So im seeking some guidance on this.

The message in kafka looks like

 ![image](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/4/48e92187bdf94e8a9ba67926511efb339e0685bf.png)

 ![image](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/6/65fd20d4bb346470df2560c1260d0d6c1eb0610f.png)

And, based on this, i want data prepper to read the key, and then use that as the index for the document. But im struggling to find out how to do this in the documentation.

Can i get some advice please?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/3/33547ea01a5b12dcca2958411d3edd97ae2ea8c1.png) [@system](https://forum.opensearch.org/u/system)\
**Post date:** [July 12, 2024, 1:55am UTC](https://forum.opensearch.org/t/use-kafka-mesage-key-as-index-route/19321/2 "2024-07-12T01:55:56Z")

</div>

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