# Escape specialcharacters in grok

**URL:** <https://discuss.elastic.co/t/escape-specialcharacters-in-grok/207060>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [November 8, 2019, 6:57am UTC](https://discuss.elastic.co/t/escape-specialcharacters-in-grok/207060 "2019-11-08T06:57:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tinkerbell](https://avatars.discourse-cdn.com/v4/letter/t/ac91a4/32.png) [@Tinkerbell](https://discuss.elastic.co/u/Tinkerbell)\
**Post date:** [November 8, 2019, 6:57am UTC](https://discuss.elastic.co/t/escape-specialcharacters-in-grok/207060/1 "2019-11-08T06:57:20Z")

</div>

How do we escape special characters in grok pattern.  
The below fails on this text.  
Log Line :  
`2019-09-03 11:52:56.387 - [INFO] - from [Class:xxx.yyy.CLASSNAME Method:METHOD] in 29 - Invalid Key and Password 1234567XXXXXX YYYYY`  
Grok Pattern:  
`%{TIMESTAMP_ISO8601:LogTimestamp} - \[%{LOGLEVEL:Loglevel}\] - from \[Class:%{JAVACLASS:Classname} Method:%{WORD:Method}\] in %{NUMBER:num} - Invalid Key and Password %{WORD:Key} %{WORD:Password}`

Whenever there is some special chars in last word ie. $YYYYY or YYY$YY , the grok fails. Can you please help me what should be done here to escape special chars ?

---

<div class="post-metadata">

**Author:** ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)\
**Post date:** [November 15, 2019, 9:21am UTC](https://discuss.elastic.co/t/escape-specialcharacters-in-grok/207060/2 "2019-11-15T09:21:40Z")

</div>

Hi @Tinkerbell,

WORD is not the right pattern for a password. Perhaps in this case you could use `%{GREEDYDATA}`? It will catch anything beyond that point. You can check the full list of available patterns here: [https://github.com/logstash-plugins/logstash-patterns-core/blob/master/patterns/grok-patterns](https://github.com/logstash-plugins/logstash-patterns-core/blob/master/patterns/grok-patterns)

---

<div class="post-metadata">

**Author:** ![Tinkerbell](https://avatars.discourse-cdn.com/v4/letter/t/ac91a4/32.png) [@Tinkerbell](https://discuss.elastic.co/u/Tinkerbell)\
**Post date:** [November 21, 2019, 6:45am UTC](https://discuss.elastic.co/t/escape-specialcharacters-in-grok/207060/3 "2019-11-21T06:45:19Z")

</div>

GREEDYDATA doesnot work. How do we use patterns in grok expressions ?

---

<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 19, 2019, 6:45am UTC](https://discuss.elastic.co/t/escape-specialcharacters-in-grok/207060/4 "2019-12-19T06:45:28Z")

</div>

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