# Ignoring text and carriage return characters with Grok

**URL:** <https://discuss.elastic.co/t/ignoring-text-and-carriage-return-characters-with-grok/65917>\
**Category:** Logstash\
**Created:** [November 13, 2016, 7:42pm UTC](https://discuss.elastic.co/t/ignoring-text-and-carriage-return-characters-with-grok/65917 "2016-11-13T19:42:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![espogian](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@espogian](https://discuss.elastic.co/u/espogian)\
**Post date:** [November 13, 2016, 7:42pm UTC](https://discuss.elastic.co/t/ignoring-text-and-carriage-return-characters-with-grok/65917/1 "2016-11-13T19:42:47Z")

</div>

Hello, how can I manage log lines which have multiple /n and /r characters with Grok?  
My situation is like:

`CSeq:696603683 ACK\r\nMax-Forwards:70\r\nContent-Length:0`

And I'm interested in CSeq and Content-Length. Max-Forwards is not always present, so I want to ignore it.  
I'm using this Grok pattern:

```
grok {
  match => {
    "message" => "%{BASE10NUM:CSeqSequenceNumber}\s%{GREEDYDATA:CSeqMethod}\s+(((.|\n)*))?Content-Length:\s%{BASE10NUM:Content-Length}"
  }

```

But the pipeline does not start, and the reason is the pattern `(((.|\n)*))?` which I have used to ignore `Max-Forwards:70\r\n`.

---

<div class="post-metadata">

**Author:** ![espogian](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@espogian](https://discuss.elastic.co/u/espogian)\
**Post date:** [November 14, 2016, 7:59am UTC](https://discuss.elastic.co/t/ignoring-text-and-carriage-return-characters-with-grok/65917/2 "2016-11-14T07:59:29Z")

</div>

I think I found a viable solution by adding a gsub filter which substitutes /n and /r with "".

---

<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:** [December 12, 2016, 7:59am UTC](https://discuss.elastic.co/t/ignoring-text-and-carriage-return-characters-with-grok/65917/3 "2016-12-12T07:59:32Z")

</div>

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