honzahommer / grok-js

Regular expression template library for Node.js inspired by logstash grok filter module
ISC License
14 stars 6 forks source link

Type not working #28

Closed pchakour closed 4 years ago

pchakour commented 4 years ago

Hello,

I'm trying to use the grok-js module with the following pattern : %{TIMESTAMP_ISO8601:date} \| %{IP:client} \| %{WORD:method} \| %{URIPATHPARAM:request} \| %{NUMBER:bytes:int} \| %{NUMBER:duration:int}

and the following line : 2018-04-11 15:26:04.756 | 192.168.0.19 | GET | /uri | 18 | 2

Unfortunately, the module doesn't work with types. If I change the pattern like this %{TIMESTAMP_ISO8601:date} \| %{IP:client} \| %{WORD:method} \| %{URIPATHPARAM:request} \| %{NUMBER:bytes} \| %{NUMBER:duration}

Everything works.

So to fix this issue, I had to change the subPatternsRegex

From

 const subPatternsRegex = /%\{[A-Z0-9_]+(?::[A-Za-z0-9_]+)?\}/g;

To

const subPatternsRegex = /%\{[A-Z0-9_]+(?::[A-Za-z0-9_]+)?(?::[a-z]+)?\}/g;
honzahommer commented 4 years ago

@pchakour Thanks for submitting issue. I will try to look closer asap. I need to be sure there will be no issues after regex update.