Skip to content

Commit

Permalink
ingest: grok remove duplicated patterns (#35886)
Browse files Browse the repository at this point in the history
This commit removes the redundant (and incorrect) JAVACLASS
and JAVAFILE grok patterns. This helps to keep parity with 
Logstash's patterns. 

See also: logstash-plugins/logstash-patterns-core#237
 
closes #35699
  • Loading branch information
pendext authored and jakelandis committed Nov 26, 2018
1 parent e02ec87 commit 4f17f1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 0 additions & 2 deletions libs/grok/src/main/resources/patterns/java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ JAVAMETHOD (?:(<init>)|[a-zA-Z$_][a-zA-Z$_0-9]*)
JAVASTACKTRACEPART %{SPACE}at %{JAVACLASS:class}\.%{JAVAMETHOD:method}\(%{JAVAFILE:file}(?::%{NUMBER:line})?\)
# Java Logs
JAVATHREAD (?:[A-Z]{2}-Processor[\d]+)
JAVACLASS (?:[a-zA-Z0-9-]+\.)+[A-Za-z0-9$]+
JAVAFILE (?:[A-Za-z0-9_.-]+)
JAVASTACKTRACEPART at %{JAVACLASS:class}\.%{WORD:method}\(%{JAVAFILE:file}:%{NUMBER:line}\)
JAVALOGMESSAGE (.*)
# MMM dd, yyyy HH:mm:ss eg: Jan 9, 2014 7:13:13 AM
Expand Down
10 changes: 10 additions & 0 deletions libs/grok/src/test/java/org/elasticsearch/grok/GrokTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,16 @@ public void testUnsupportedBracketsInFieldName() {
assertNull(matches);
}

public void testJavaClassPatternWithUnderscore() {
Grok grok = new Grok(basePatterns, "%{JAVACLASS}");
assertThat(grok.match("Test_Class.class"), is(true));
}

public void testJavaFilePatternWithSpaces() {
Grok grok = new Grok(basePatterns, "%{JAVAFILE}");
assertThat(grok.match("Test Class.java"), is(true));
}

private void assertGrokedField(String fieldName) {
String line = "foo";
Grok grok = new Grok(basePatterns, "%{WORD:" + fieldName + "}");
Expand Down

0 comments on commit 4f17f1e

Please sign in to comment.