[ 
https://issues.apache.org/jira/browse/METRON-295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15651389#comment-15651389
 ] 

ASF GitHub Bot commented on METRON-295:
---------------------------------------

Github user kylerichardson commented on a diff in the pull request:

    https://github.com/apache/incubator-metron/pull/338#discussion_r87226233
  
    --- Diff: 
metron-platform/metron-parsers/src/main/java/org/apache/metron/parsers/ScriptParser.java
 ---
    @@ -0,0 +1,175 @@
    +package org.apache.metron.parsers;
    +
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.io.InputStreamReader;
    +import java.io.Serializable;
    +import java.text.ParseException;
    +import java.text.SimpleDateFormat;
    +import java.util.ArrayList;
    +import java.util.Date;
    +import java.util.List;
    +import java.util.Map;
    +
    +import javax.script.Invocable;
    +import javax.script.ScriptEngine;
    +import javax.script.ScriptEngineFactory;
    +import javax.script.ScriptEngineManager;
    +
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.fs.FileSystem;
    +import org.apache.hadoop.fs.Path;
    +import org.apache.metron.common.Constants;
    +import org.apache.metron.parsers.interfaces.MessageParser;
    +import org.json.simple.JSONObject;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import com.google.common.base.Joiner;
    +import com.google.common.base.Splitter;
    +
    +public class ScriptParser implements 
MessageParser<JSONObject>,Serializable{
    +   
    +   protected static final Logger LOG = 
LoggerFactory.getLogger(ScriptParser.class);
    +   protected String scriptPath;
    +   protected ScriptEngine engine;
    +   protected String parseFunction;
    +   protected String language;
    +   protected String commonScript="/scripts/";
    +   protected List<String> timeFields = new ArrayList<>();
    +   protected String timestampField;
    +   protected SimpleDateFormat dateFormat = new 
SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S z");
    +
    +   @Override
    +   public void configure(Map<String, Object> config) {
    +           // TODO Auto-generated method stub
    +           this.scriptPath=(String) config.get("path");
    +           this.parseFunction=(String)config.get("function");
    +           this.language=(String)config.get("language");
    +           this.commonScript=this.commonScript+language+"/common";
    +           if(this.parseFunction==null)
    +                   this.parseFunction="parse";
    +   }
    +   //Should this be sent to the interface as a default method?
    +   public InputStream openInputStream(String streamName) throws 
IOException {
    +       FileSystem fs = FileSystem.get(new Configuration());
    --- End diff --
    
    I agree with the desire for consistency; however, I would potentially be 
concerned about the user experience of putting scripts (especially ones with 
external library dependencies) into zookeeper. We would need to make this as 
clean as possible.


> Script parsing bolt 
> --------------------
>
>                 Key: METRON-295
>                 URL: https://issues.apache.org/jira/browse/METRON-295
>             Project: Metron
>          Issue Type: New Feature
>    Affects Versions: 0.2.1BETA
>            Reporter: James Sirota
>            Assignee: Karthik Narayanan
>            Priority: Minor
>              Labels: newbie, platform
>             Fix For: 0.2.2BETA
>
>
> In addition to having a Grok parsing bolt we need a bolt that can execute a 
> script in order to parse a telemetry.  This way you can still script the 
> parsing for telemetries for which Grok expressions are too complex, but still 
> don't have to define a java parser 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to