From 0baffda390fdbe84239aae25ee433f5b886c1d6c Mon Sep 17 00:00:00 2001 From: John Date: Mon, 26 Nov 2018 12:13:46 -0500 Subject: [PATCH] ingest: grok remove duplicated patterns (#35886) This commit removes the redundant (and incorrect) JAVACLASS and JAVAFILE grok patterns. This helps to keep parity with Logstash's patterns. See also: https://github.com/logstash-plugins/logstash-patterns-core/pull/237 closes #35699 --- libs/grok/src/main/resources/patterns/java | 2 -- .../test/java/org/elasticsearch/grok/GrokTests.java | 10 ++++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/grok/src/main/resources/patterns/java b/libs/grok/src/main/resources/patterns/java index e968006ad2d..01766b8ebd1 100644 --- a/libs/grok/src/main/resources/patterns/java +++ b/libs/grok/src/main/resources/patterns/java @@ -7,8 +7,6 @@ JAVAMETHOD (?:()|[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 diff --git a/libs/grok/src/test/java/org/elasticsearch/grok/GrokTests.java b/libs/grok/src/test/java/org/elasticsearch/grok/GrokTests.java index f9d2055de1b..0193811a20d 100644 --- a/libs/grok/src/test/java/org/elasticsearch/grok/GrokTests.java +++ b/libs/grok/src/test/java/org/elasticsearch/grok/GrokTests.java @@ -477,6 +477,16 @@ public class GrokTests extends ESTestCase { 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 + "}");