# Logstash is escaping message!

**URL:** <https://discuss.elastic.co/t/logstash-is-escaping-message/51640>\
**Category:** Logstash\
**Created:** [June 2, 2016, 3:19am UTC](https://discuss.elastic.co/t/logstash-is-escaping-message/51640 "2016-06-02T03:19:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonathanpmartins](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@jonathanpmartins](https://discuss.elastic.co/u/jonathanpmartins)\
**Post date:** [June 2, 2016, 3:19am UTC](https://discuss.elastic.co/t/logstash-is-escaping-message/51640/1 "2016-06-02T03:19:08Z")

</div>

Can I have access to the raw message before filters? My message is full with "\x22".  
The easy way to deal with it is to use ruby and unpack the string, but...  
Logstash escape everything an put another backslash in front of it, so now my message is full with "\\x22".  
No matter what I try I cannot remove that one backslash, if I leave one single backslash using mutator or ruby regex. logstash will ever put a escape backslash there.  
Do I have access to the raw message? so I can filter with ruby and unpack the message correctly before it pass down to the chain...  
Im very stuck with this...

---

<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:** [June 2, 2016, 7:10am UTC](https://discuss.elastic.co/t/logstash-is-escaping-message/51640/2 "2016-06-02T07:10:50Z")

</div>

Yeah, the Logstash configuration language doesn't treat backslashes in a very good way. This works:

```nohighlight
filter {
  ruby {
    code => "
      event['message'] = event['message'].gsub([92].pack('U') + 'x22',
                                               [34].pack('U'))
    "
  }
}

```

92 is the codepoint for backslash and 34 the codepoint for a double quote. It should be easy to generalize this code to support any \xNN sequences.

---

<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:54am UTC](https://discuss.elastic.co/t/logstash-is-escaping-message/51640/3 "2017-07-06T04:54:52Z")

</div>


