Siegfried Goeschl created FREEMARKER-181:
--------------------------------------------

             Summary: [freemarker-generator] Support custom pattern definitions 
for Grok tool
                 Key: FREEMARKER-181
                 URL: https://issues.apache.org/jira/browse/FREEMARKER-181
             Project: Apache Freemarker
          Issue Type: Bug
            Reporter: Siegfried Goeschl


Need to parse through a bunch of server log files to extract response times but 
I want to define the required pattern definitions directly in the FTL instead 
of changing "/patterns/patterns".

So something like this should work

{code:java}
<#assign patternDefinitions = {
"MY_DATE": "%{YEAR}-%{MONTHNUM}-%{MONTHDAY}",
"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}"
}>

<#assign grok = tools.grok.compile("%{MY_SERVERLOG}", patternDefinitions)>
{code}




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to