# Remove json new line \\n

**URL:** <https://discuss.elastic.co/t/remove-json-new-line-n/175628>\
**Category:** Logstash\
**Created:** [April 5, 2019, 3:47pm UTC](https://discuss.elastic.co/t/remove-json-new-line-n/175628 "2019-04-05T15:47:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacob-N](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@Jacob-N](https://discuss.elastic.co/u/Jacob-N)\
**Post date:** [April 5, 2019, 3:47pm UTC](https://discuss.elastic.co/t/remove-json-new-line-n/175628/1 "2019-04-05T15:47:38Z")

</div>

I am pulling a JSON input via http\_poller, the data has "\n" throughout the data that I would like to remove it

Here is an example of a date that contains the "\n"

"O 151007Z FEB 17\n"

Here is my input

input{  
http\_poller{  
urls =\> {  
test1 =\> "..."  
test2 =\> {  
method =\> get  
url =\> "..."  
headers =\> {  
Accept =\> "application/json"  
}  
}  
}  
codec =\> "json"  
}  
}

I have tried  
filter{  
mutate { gsub =\> ["message", "[\n]", "" ] }  
}

and suggestions from here with no success.

> [@Remove \\n and \\t from message](https://discuss.elastic.co/t/remove-n-and-t-from-message/142620):
>
> Hi, I am trying to ingest Java exceptions into Elasticsearch via logstash. In Kibana, they show up like this, \n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)\n\tat org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)\n\tat org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)\n\tat org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)\n\tat org.apache.tomcat.util.net.NioEndpo…

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 5, 2019, 4:36pm UTC](https://discuss.elastic.co/t/remove-json-new-line-n/175628/2 "2019-04-05T16:36:40Z")

</div>

```
Do not escape the newline.

mutate { gsub => [ "message", "
", "" ] }
```

---

<div class="post-metadata">

**Author:** ![Jacob-N](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@Jacob-N](https://discuss.elastic.co/u/Jacob-N)\
**Post date:** [April 5, 2019, 6:10pm UTC](https://discuss.elastic.co/t/remove-json-new-line-n/175628/3 "2019-04-05T18:10:20Z")

</div>

My new input is

```
input {
 http_poller {
    urls => {
      test1 => ".."
      test2 => {
        method => get
        url => "..."
        headers => {
        Accept => "application/json"
        }
     }
    }
    type => "..."
    request_timeout => 60
    codec => "json"
    metadata_target => "http_poller_metadata"
  }
}
filter {
   json {
     source => "message"
   }
   mutate { gsub => [ "messages", "
 ", "" ] }
}

```

The output has not changed and is

`"O 151007Z FEB 17\n"`

In Kibana, the "\n" is only visible in the JSON source, but it causes issues when trying to parse the date as I am only able to parse dates without the new line \n "O 151007Z FEB 17" correctly.

---

<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:** [May 3, 2019, 6:10pm UTC](https://discuss.elastic.co/t/remove-json-new-line-n/175628/4 "2019-05-03T18:10:23Z")

</div>

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