25
25
*/
26
26
public final class GrokPatternCreator {
27
27
28
- private static String PREFACE = "preface" ;
29
- private static String EPILOGUE = "epilogue" ;
28
+ private static final String PREFACE = "preface" ;
29
+ private static final String EPILOGUE = "epilogue" ;
30
30
31
31
/**
32
32
* The first match in this list will be chosen, so it needs to be ordered
33
33
* such that more generic patterns come after more specific patterns.
34
34
*/
35
35
private static final List <GrokPatternCandidate > ORDERED_CANDIDATE_GROK_PATTERNS = Arrays .asList (
36
+ new GrokPatternCandidate ("TOMCAT_DATESTAMP" , "timestamp" ),
36
37
new GrokPatternCandidate ("TIMESTAMP_ISO8601" , "timestamp" ),
37
38
new GrokPatternCandidate ("DATESTAMP_RFC822" , "timestamp" ),
38
39
new GrokPatternCandidate ("DATESTAMP_RFC2822" , "timestamp" ),
@@ -41,7 +42,6 @@ public final class GrokPatternCreator {
41
42
new GrokPatternCandidate ("SYSLOGTIMESTAMP" , "timestamp" ),
42
43
new GrokPatternCandidate ("HTTPDATE" , "timestamp" ),
43
44
new GrokPatternCandidate ("CATALINA_DATESTAMP" , "timestamp" ),
44
- new GrokPatternCandidate ("TOMCAT_DATESTAMP" , "timestamp" ),
45
45
new GrokPatternCandidate ("CISCOTIMESTAMP" , "timestamp" ),
46
46
new GrokPatternCandidate ("DATE" , "date" ),
47
47
new GrokPatternCandidate ("TIME" , "time" ),
@@ -56,12 +56,10 @@ public final class GrokPatternCreator {
56
56
new GrokPatternCandidate ("IP" , "ipaddress" ),
57
57
// This already includes pre/post break conditions
58
58
new GrokPatternCandidate ("QUOTEDSTRING" , "field" , "" , "" ),
59
- // Can't use \b as the break before, because it doesn't work for negative numbers (the
60
- // minus sign is not a "word" character)
61
- new GrokPatternCandidate ("NUMBER" , "field" , "(?<!\\ w)" ),
62
- // Disallow +, - and . before hex numbers, otherwise this pattern will pick up base 10
63
- // numbers that NUMBER rejected due to preceeding characters
64
- new GrokPatternCandidate ("BASE16NUM" , "field" , "(?<![\\ w.+-])" )
59
+ // Disallow +, - and . before numbers, as well as "word" characters, otherwise we'll pick
60
+ // up numeric suffices too eagerly
61
+ new GrokPatternCandidate ("NUMBER" , "field" , "(?<![\\ w.+-])" , "(?![\\ w+-]|\\ .\\ d)" ),
62
+ new GrokPatternCandidate ("BASE16NUM" , "field" , "(?<![\\ w.+-])" , "(?![\\ w+-]|\\ .\\ w)" )
65
63
// TODO: also unfortunately can't have USERNAME in the list as it matches too broadly
66
64
// Fixing these problems with overly broad matches would require some extra intelligence
67
65
// to be added to remove inappropriate matches. One idea would be to use a dictionary,
0 commit comments