This is an automated email from the ASF dual-hosted git repository.

sgoeschl pushed a commit to branch FREEMARKER-181
in repository https://gitbox.apache.org/repos/asf/freemarker-generator.git


The following commit(s) were added to refs/heads/FREEMARKER-181 by this push:
     new 7ca6239  FREEMARKER-181 Support custom pattern definitions for Grok 
tool
7ca6239 is described below

commit 7ca6239ac939112c25a3d349523fcea72b5b8c61
Author: Siegfried Goeschl <[email protected]>
AuthorDate: Sat May 22 13:37:13 2021 +0200

    FREEMARKER-181 Support custom pattern definitions for Grok tool
---
 freemarker-generator-cli/pom.xml                   |   2 +
 .../templates/logs/csv/serverlog-to-csv.ftl        |   2 +-
 .../src/app/scripts/examples-win.args              | 109 +++++++++++++++++++++
 .../src/app/scripts/examples.args                  | 109 +++++++++++++++++++++
 .../site/markdown/cli/usage/parsing-with-grok.md   |   5 +-
 travis.sh                                          |   1 +
 6 files changed, 226 insertions(+), 2 deletions(-)

diff --git a/freemarker-generator-cli/pom.xml b/freemarker-generator-cli/pom.xml
index c21d5d9..4984b36 100644
--- a/freemarker-generator-cli/pom.xml
+++ b/freemarker-generator-cli/pom.xml
@@ -76,6 +76,8 @@
                                 <copy file="NOTICE" 
todir="./target/appassembler" />
                                 <copy 
file="./src/app/scripts/run-examples.bat" todir="./target/appassembler" />
                                 <copy file="./src/app/scripts/run-examples.sh" 
todir="./target/appassembler" />
+                                <copy file="./src/app/scripts/examples.args" 
todir="./target/appassembler" />
+                                <copy 
file="./src/app/scripts/examples-win.args" todir="./target/appassembler" />
                                 <copy todir="./target/appassembler/config">
                                     <fileset dir="src/app/config" />
                                 </copy>
diff --git 
a/freemarker-generator-cli/src/app/examples/templates/logs/csv/serverlog-to-csv.ftl
 
b/freemarker-generator-cli/src/app/examples/templates/logs/csv/serverlog-to-csv.ftl
index a8e9752..bccad9a 100644
--- 
a/freemarker-generator-cli/src/app/examples/templates/logs/csv/serverlog-to-csv.ftl
+++ 
b/freemarker-generator-cli/src/app/examples/templates/logs/csv/serverlog-to-csv.ftl
@@ -25,7 +25,7 @@
 "MY_TIMESTAMP": "%{MY_DATE:date} %{TIME:time},%{INT:millis}",
 "MY_MODULE": "\\[%{NOTSPACE}\\]",
 "MY_THREAD": "\\(%{NOTSPACE}\\)",
-"MY_SERVERLOG": "%{MY_TIMESTAMP} %{LOGLEVEL}%{SPACE:UNWANTED}%{MY_MODULE} 
%{MY_THREAD} message response handled in: %{INT:response_time} ms; 
%{GREEDYDATA:UNWANTED}"
+"MY_SERVERLOG": "^%{MY_TIMESTAMP} %{LOGLEVEL}%{SPACE:UNWANTED}%{MY_MODULE} 
%{MY_THREAD} message response handled in: %{INT:response_time} ms; 
%{GREEDYDATA:UNWANTED}$"
 }>
 
 <#-- Instantiante the grok tool -->
diff --git a/freemarker-generator-cli/src/app/scripts/examples-win.args 
b/freemarker-generator-cli/src/app/scripts/examples-win.args
new file mode 100644
index 0000000..4219adf
--- /dev/null
+++ b/freemarker-generator-cli/src/app/scripts/examples-win.args
@@ -0,0 +1,109 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Proof of concept for pioclo's @-files support for Windows
+
+#############################################################################
+# Info
+#############################################################################
+
+-t freemarker-generator\info.ftl -s README.md -o target\out\info.txt
+
+#############################################################################
+# Demo
+#############################################################################
+
+-t examples\templates\demo.ftl -s README.md -o target\out\demo.txt
+
+#############################################################################
+# DataSources
+#############################################################################
+
+-t examples\templates\datasources.ftl -s :data=examples\data -o 
target\out\datasources-01.txt
+-t examples\templates\datasources.ftl -s https://xkcd.com\info.0.json -s 
https://www.google.com -o target\out\datasources-02.txt
+
+#############################################################################
+# CSV
+#############################################################################
+
+-t freemarker-generator\csv\html\transform.ftl -s 
examples\data\csv\contract.csv -o target\out\contract.html
+-t freemarker-generator\csv\md\transform.ftl -s examples\data\csv\contract.csv 
-o target\out\contract.md
+-t examples\templates\csv\shell\curl.ftl -s examples\data\csv\user.csv -o 
target\out\curl.sh
+
+#############################################################################
+# Grok
+#############################################################################
+
+-t examples\templates\accesslog\combined-access.ftl -s 
examples\data\accesslog\combined-access.log -o 
target\out\combined-access.log.txt
+-t examples\templates\logs\csv\serverlog-to-csv.ftl -s examples\data\logs -o 
target\out\server.log.csv
+
+#############################################################################
+# Excel
+#############################################################################
+
+-t examples\templates\excel\dataframe\transform.ftl -s 
examples\data\excel\test.xls -o target\out\test.xls.dataframe.txt
+-t freemarker-generator\excel\html\transform.ftl -s 
examples\data\excel\test.xls -o target\out\test.xls.html
+-t freemarker-generator\excel\html\transform.ftl -s 
examples\data\excel\test.xlsx -o target\out\test.xslx.html
+-t freemarker-generator\excel\html\transform.ftl -s 
examples\data\excel\test-multiple-sheets.xlsx -o 
target\out\test-multiple-sheets.xlsx.html
+-t freemarker-generator\excel\md\transform.ftl -s 
examples\data\excel\test-multiple-sheets.xlsx -o 
target\out\test-multiple-sheets.xlsx.md
+-t freemarker-generator\excel\csv\transform.ftl -s 
examples\data\excel\test-multiple-sheets.xlsx -o 
target\out\test-multiple-sheets.xlsx.csv
+
+#############################################################################
+# HTML
+#############################################################################
+
+-t examples\templates\html\csv\dependencies.ftl -s 
examples\data\html\dependencies.html -o target\out\dependencies.csv
+-t examples\templates\html\txt\licence.ftl -s 
examples\data\html\dependencies.html -o target\out\licence.txt
+
+#############################################################################
+# Java Faker
+#############################################################################
+
+-t examples\templates\javafaker\csv\testdata.ftl -o target\out\testdata.csv
+
+#############################################################################
+# JSON
+#############################################################################
+
+-t examples\templates\json\csv\swagger-endpoints.ftl -s 
examples\data\json\swagger-spec.json -o target\out\swagger-spec.csv
+-t freemarker-generator\json\yaml\transform.ftl -s 
examples\data\json\swagger-spec.json -o target\out\swagger-spec.yaml
+-t examples\templates\json\md\github-users.ftl -s 
examples\data\json\github-users.json -o target\out\github-users.md
+
+#############################################################################
+# Properties
+#############################################################################
+
+-t examples\templates\properties\csv\locker-test-users.ftl -s 
examples\data\properties -o target\out\locker-test-users.csv
+
+#############################################################################
+# Template Directory
+#############################################################################
+
+-t examples\data\template -PNGINX_HOSTNAME=localhost -o target\out\template
+
+#############################################################################
+# XML
+#############################################################################
+
+-t examples\templates\xml\txt\recipients.ftl -s 
examples\data\xml\recipients.xml -o target\out\recipients.txt
+
+#############################################################################
+# YAML
+#############################################################################
+
+-t examples\templates\yaml\txt\transform.ftl -s 
examples\data\yaml\customer.yaml -o target\out\customer.txt
+-t freemarker-generator\yaml\json\transform.ftl -s 
examples\data\yaml\swagger-spec.yaml -o target\out\swagger-spec.json
\ No newline at end of file
diff --git a/freemarker-generator-cli/src/app/scripts/examples.args 
b/freemarker-generator-cli/src/app/scripts/examples.args
new file mode 100644
index 0000000..c867988
--- /dev/null
+++ b/freemarker-generator-cli/src/app/scripts/examples.args
@@ -0,0 +1,109 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Proof of concept for pioclo's @-files support for Linux/MacOS
+
+#############################################################################
+# Info
+#############################################################################
+
+-t freemarker-generator/info.ftl -s README.md -o target/out/info.txt
+
+#############################################################################
+# Demo
+#############################################################################
+
+-t examples/templates/demo.ftl -s README.md -o target/out/demo.txt
+
+#############################################################################
+# DataSources
+#############################################################################
+
+-t examples/templates/datasources.ftl -s :data=examples/data -o 
target/out/datasources-01.txt
+-t examples/templates/datasources.ftl -s https://xkcd.com/info.0.json -s 
https://www.google.com -o target/out/datasources-02.txt
+
+#############################################################################
+# CSV
+#############################################################################
+
+-t freemarker-generator/csv/html/transform.ftl -s 
examples/data/csv/contract.csv -o target/out/contract.html
+-t freemarker-generator/csv/md/transform.ftl -s examples/data/csv/contract.csv 
-o target/out/contract.md
+-t examples/templates/csv/shell/curl.ftl -s examples/data/csv/user.csv -o 
target/out/curl.sh
+
+#############################################################################
+# Grok
+#############################################################################
+
+-t examples/templates/accesslog/combined-access.ftl -s 
examples/data/accesslog/combined-access.log -o 
target/out/combined-access.log.txt
+-t examples/templates/logs/csv/serverlog-to-csv.ftl -s examples/data/logs -o 
target/out/server.log.csv
+
+#############################################################################
+# Excel
+#############################################################################
+
+-t examples/templates/excel/dataframe/transform.ftl -s 
examples/data/excel/test.xls -o target/out/test.xls.dataframe.txt
+-t freemarker-generator/excel/html/transform.ftl -s 
examples/data/excel/test.xls -o target/out/test.xls.html
+-t freemarker-generator/excel/html/transform.ftl -s 
examples/data/excel/test.xlsx -o target/out/test.xslx.html
+-t freemarker-generator/excel/html/transform.ftl -s 
examples/data/excel/test-multiple-sheets.xlsx -o 
target/out/test-multiple-sheets.xlsx.html
+-t freemarker-generator/excel/md/transform.ftl -s 
examples/data/excel/test-multiple-sheets.xlsx -o 
target/out/test-multiple-sheets.xlsx.md
+-t freemarker-generator/excel/csv/transform.ftl -s 
examples/data/excel/test-multiple-sheets.xlsx -o 
target/out/test-multiple-sheets.xlsx.csv
+
+#############################################################################
+# HTML
+#############################################################################
+
+-t examples/templates/html/csv/dependencies.ftl -s 
examples/data/html/dependencies.html -o target/out/dependencies.csv
+-t examples/templates/html/txt/licence.ftl -s 
examples/data/html/dependencies.html -o target/out/licence.txt
+
+#############################################################################
+# Java Faker
+#############################################################################
+
+-t examples/templates/javafaker/csv/testdata.ftl -o target/out/testdata.csv
+
+#############################################################################
+# JSON
+#############################################################################
+
+-t examples/templates/json/csv/swagger-endpoints.ftl -s 
examples/data/json/swagger-spec.json -o target/out/swagger-spec.csv
+-t freemarker-generator/json/yaml/transform.ftl -s 
examples/data/json/swagger-spec.json -o target/out/swagger-spec.yaml
+-t examples/templates/json/md/github-users.ftl -s 
examples/data/json/github-users.json -o target/out/github-users.md
+
+#############################################################################
+# Properties
+#############################################################################
+
+-t examples/templates/properties/csv/locker-test-users.ftl -s 
examples/data/properties -o target/out/locker-test-users.csv
+
+#############################################################################
+# Template Directory
+#############################################################################
+
+-t examples/data/template -PNGINX_HOSTNAME=localhost -o target/out/template
+
+#############################################################################
+# XML
+#############################################################################
+
+-t examples/templates/xml/txt/recipients.ftl -s 
examples/data/xml/recipients.xml -o target/out/recipients.txt
+
+#############################################################################
+# YAML
+#############################################################################
+
+-t examples/templates/yaml/txt/transform.ftl -s 
examples/data/yaml/customer.yaml -o target/out/customer.txt
+-t freemarker-generator/yaml/json/transform.ftl -s 
examples/data/yaml/swagger-spec.yaml -o target/out/swagger-spec.json
\ No newline at end of file
diff --git 
a/freemarker-generator-cli/src/site/markdown/cli/usage/parsing-with-grok.md 
b/freemarker-generator-cli/src/site/markdown/cli/usage/parsing-with-grok.md
index b758527..7e974b5 100644
--- a/freemarker-generator-cli/src/site/markdown/cli/usage/parsing-with-grok.md
+++ b/freemarker-generator-cli/src/site/markdown/cli/usage/parsing-with-grok.md
@@ -83,7 +83,7 @@ In technical terms the FTL
 "MY_TIMESTAMP": "%{MY_DATE:date} %{TIME:time},%{INT:millis}",
 "MY_MODULE": "\\[%{NOTSPACE}\\]",
 "MY_THREAD": "\\(%{NOTSPACE}\\)",
-"MY_SERVERLOG": "%{MY_TIMESTAMP} %{LOGLEVEL}%{SPACE:UNWANTED}%{MY_MODULE} 
%{MY_THREAD} message response handled in: %{INT:response_time} ms; 
%{GREEDYDATA:UNWANTED}"
+"MY_SERVERLOG": "^%{MY_TIMESTAMP} %{LOGLEVEL}%{SPACE:UNWANTED}%{MY_MODULE} 
%{MY_THREAD} message response handled in: %{INT:response_time} ms; 
%{GREEDYDATA:UNWANTED}$"
 }>
 
 <#-- Instantiante the grok tool -->
@@ -116,3 +116,6 @@ TIMESTAMP;MILLIS
 2021-05-18T21:00:32.140;162
 ```
 
+### Performance Considerations
+
+When processing large logfiles you may experience performance issues - using 
regexp anchors as decribed in [Killing your Logstash performance with 
Grok](https://medium.com/@momchil.dev/killing-your-logstash-performance-with-grok-f5f23ae47956)
 might help. Using regexp anchors reduced the execution time by 50% when 
parsing through 3 GB of logs with only small percentage of matching lines.
diff --git a/travis.sh b/travis.sh
index 61d2161..a962f8e 100755
--- a/travis.sh
+++ b/travis.sh
@@ -19,6 +19,7 @@
 # Simulate the Travis build locally
 mvn clean install site site:stage
 cd ./freemarker-generator-cli/target/appassembler/
+sh ./bin/freemarker-generator @examples.args
 sh ./run-examples.sh
 cd ../../../freemarker-generator-maven-plugin-sample
 mvn clean package

Reply via email to