# How to avoid multiple escaping

**URL:** <https://discuss.elastic.co/t/how-to-avoid-multiple-escaping/68737>\
**Category:** Logstash\
**Created:** [December 12, 2016, 4:31pm UTC](https://discuss.elastic.co/t/how-to-avoid-multiple-escaping/68737 "2016-12-12T16:31:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikolay\_Shushkin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikolay_shushkin/32/13809_2.png) [@Nikolay\_Shushkin](https://discuss.elastic.co/u/Nikolay_Shushkin)\
**Post date:** [December 12, 2016, 4:31pm UTC](https://discuss.elastic.co/t/how-to-avoid-multiple-escaping/68737/1 "2016-12-12T16:31:09Z")

</div>

Hi,

There is the following pipeline for Apache log:

Logstash 2.2.2

```
input {
  beats {
    port => 4000
  }
}
output {
    kafka {
	topic_id => "my-topic"
	bootstrap_servers => "kafka-server"
    }
}

```

Kafka 0.10.0.0

Logstash 5.1.1

```
input {
    kafka {
	bootstrap_servers => "kafka-server"
        type => "my-type"
        topics => ["my-topic"]
    }
}
output {
    if [type] == "my-type" {
        file {
            path => "/var/log/logstash/my-type.txt"
        }
    }
}

```

The result is double escaping in message:

> {  
> "@timestamp": "2016-12-12T15:23:23.894Z",  
> "@version": "1",  
> "message": "{"message":"127.0.0.1 - - 12/Dec/2016:15:15:55 +0000 \\"PUT /libs/mpick/entropology/inector.aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeeee.json HTTP/1.1\\" 200 165  
> ...................

Where it happens and how it can be avoided?  
Thanks in advance.

---

<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:** [December 13, 2016, 6:38am UTC](https://discuss.elastic.co/t/how-to-avoid-multiple-escaping/68737/2 "2016-12-13T06:38:05Z")

</div>

It looks like you should have `codec => json` set for your kafka input.

---

<div class="post-metadata">

**Author:** ![Nikolay\_Shushkin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikolay_shushkin/32/13809_2.png) [@Nikolay\_Shushkin](https://discuss.elastic.co/u/Nikolay_Shushkin)\
**Post date:** [December 13, 2016, 1:17pm UTC](https://discuss.elastic.co/t/how-to-avoid-multiple-escaping/68737/3 "2016-12-13T13:17:31Z")

</div>

That is it!  
Perfect!  
Thanks, magnusbaeck!  
(I tried "codec =\> json" in output.kafka before, but it did not work)

---

<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:** [January 10, 2017, 1:17pm UTC](https://discuss.elastic.co/t/how-to-avoid-multiple-escaping/68737/4 "2017-01-10T13:17:34Z")

</div>

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