thekrakken / java-grok

Simple API that allows you to easily parse logs and other files
http://grok.nflabs.com/
Other
360 stars 151 forks source link

Custom date format doesn't work with commas #97

Closed joschi closed 6 years ago

joschi commented 6 years ago

Custom date formats (e. g. %{PATTERN:my_date;datetime;dd/MM/yyyy}) don't seem to work if comma characters are being used in the date pattern.

If the date pattern contains a comma, Grok fails with the following exception:

java.util.regex.PatternSyntaxException: Illegal repetition near index 4
Foo %{DATA:result;date;yyyy,MM,dd} Bar
    ^

    at java.base/java.util.regex.Pattern.error(Pattern.java:2010)
    at java.base/java.util.regex.Pattern.closure(Pattern.java:3307)
    at java.base/java.util.regex.Pattern.sequence(Pattern.java:2196)
    at java.base/java.util.regex.Pattern.expr(Pattern.java:2051)
    at java.base/java.util.regex.Pattern.compile(Pattern.java:1773)
    at java.base/java.util.regex.Pattern.<init>(Pattern.java:1422)
    at java.base/java.util.regex.Pattern.compile(Pattern.java:1082)
    at io.krakens.grok.api.Grok.<init>(Grok.java:69)
    at io.krakens.grok.api.GrokCompiler.compile(GrokCompiler.java:197)