# Filtering binary data from an ASCII string

**URL:** <https://discuss.elastic.co/t/filtering-binary-data-from-an-ascii-string/131392>\
**Category:** Logstash\
**Created:** [May 11, 2018, 4:50am UTC](https://discuss.elastic.co/t/filtering-binary-data-from-an-ascii-string/131392 "2018-05-11T04:50:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![p4w4n](https://avatars.discourse-cdn.com/v4/letter/p/cab0a1/32.png) [@p4w4n](https://discuss.elastic.co/u/p4w4n)\
**Post date:** [May 11, 2018, 4:50am UTC](https://discuss.elastic.co/t/filtering-binary-data-from-an-ascii-string/131392/1 "2018-05-11T04:50:30Z")

</div>

Hi,

I have a mainframe log with message containing some binary data. I would like to trim that binary data in Logstash before sending it to elasticsearch. I am not able to find a way. Below is the sample data that I am getting:

"\u0000\u0000\u0000C\u0000 \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000{"response":{"message":"Hello World"}}"

I want to trim all the data before {"response":{"message":"Hello World"}}"

can someone please help.

thanks,  
Pawan

---

<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:** [May 14, 2018, 8:41am UTC](https://discuss.elastic.co/t/filtering-binary-data-from-an-ascii-string/131392/2 "2018-05-14T08:41:50Z")

</div>

You might be able to use a mutate filter's gsub option to remove all leading non-printable characters. Otherwise you can write some Ruby code in a ruby filter.

---

<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:** [June 11, 2018, 8:41am UTC](https://discuss.elastic.co/t/filtering-binary-data-from-an-ascii-string/131392/3 "2018-06-11T08:41:53Z")

</div>

Closed on June 11, 2018, 8:41am UTC

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