How can I escape backslash in logstash grok pattern?

11,455

You escape a backslash with a backslash. \\ matches \

%{IPORHOST:remoteip} \- \- \[%{HTTPDATE:timestamp}\] %{WORD:verb} %{NOTSPACE:request} HTTP/%{NUMBER:httpversion} %{NUMBER:status} %{NUMBER:requestNum} \\"\-\\" %{QUOTEDSTRING:agent}

Also, when it comes to escaping hyphens, check out this answer.

Share:
11,455

Related videos on Youtube

raygo
Author by

raygo

Proud geek-nerd, papercut survivor, gifted napper, PHP ninja.

Updated on June 04, 2022

Comments

  • raygo
    raygo almost 2 years

    This is my log:

    68.192.186.96 - - [18/May/2015:12:54:42 +0000] GET http://test.com/sectionId/592/apiVersion/2/type/json HTTP/1.1 200 575 \"-\" \"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/537.36\" \"icon_seq=0; PHPSESSID=frmnhfrrc25ullikbv71thc283\"
    

    this is my pattern

    %{IPORHOST:remoteip} \- \- \[%{HTTPDATE:timestamp}\] %{WORD:verb} %{NOTSPACE:request} HTTP/%{NUMBER:httpversion} %{NUMBER:status} %{NUMBER:requestNum} \"\-\" %{QUOTEDSTRING:agent}
    

    When I check it's giving me problems with the backslashes in the log. How can I escape them? thanks!