# Getting Elasticsearch index from Logstash message content

**URL:** <https://discuss.elastic.co/t/getting-elasticsearch-index-from-logstash-message-content/57129>\
**Category:** Logstash\
**Created:** [August 3, 2016, 4:15pm UTC](https://discuss.elastic.co/t/getting-elasticsearch-index-from-logstash-message-content/57129 "2016-08-03T16:15:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tsury](https://avatars.discourse-cdn.com/v4/letter/t/71c47a/32.png) [@Tsury](https://discuss.elastic.co/u/Tsury)\
**Post date:** [August 3, 2016, 4:15pm UTC](https://discuss.elastic.co/t/getting-elasticsearch-index-from-logstash-message-content/57129/1 "2016-08-03T16:15:05Z")

</div>

Hi.

I have a FileBeat -\> Kafka -\> Logstash -\> Elasticsearch setup, and the file that FileBeat monitors produces JSON lines with { "index" : "myIndex" }. Everything is sent to Kafka to the same topic and from there to Logstash. I would like Logstash to determine the Elasticsearch index according to this JSON field. The thing is FileBeat and Kafka wraps the message in such a way that my JSON is triple encoded since it is nested inside a message -\> beat -\> message hierarchy.

What can I do to solve this?  
Thanks.

---

<div class="post-metadata">

**Author:** ![Joe\_Lawson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_lawson/32/3390_2.png) [@Joe\_Lawson](https://discuss.elastic.co/u/Joe_Lawson)\
**Post date:** [August 3, 2016, 6:06pm UTC](https://discuss.elastic.co/t/getting-elasticsearch-index-from-logstash-message-content/57129/2 "2016-08-03T18:06:59Z")

</div>

Try using [Event Dependent Configuration](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#sprintf)

---

<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:** [July 6, 2017, 4:45am UTC](https://discuss.elastic.co/t/getting-elasticsearch-index-from-logstash-message-content/57129/3 "2017-07-06T04:45:02Z")

</div>


