当前位置: 首页>>代码示例>>Java>>正文


Java Match.toMap方法代码示例

本文整理汇总了Java中oi.thekraken.grok.api.Match.toMap方法的典型用法代码示例。如果您正苦于以下问题:Java Match.toMap方法的具体用法?Java Match.toMap怎么用?Java Match.toMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oi.thekraken.grok.api.Match的用法示例。


在下文中一共展示了Match.toMap方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parserGrok

import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
/**
 * 正则解析
 * @param event
 * @param value
 */
public  void parserGrok(Map<String,Object> event,String value){
	try{
		Map<String,String> patterns11 =grok.getPatterns();
		Match match =grok.match(value);
		match.captures();
		Map<String,Object> map =match.toMap();
		if(map!=null&&map.size()>0){
			Set<Map.Entry<String,Object>> sets =map.entrySet();
			for(Map.Entry<String,Object> set:sets){
				String key = set.getKey();
				if(!patterns11.containsKey(key)){
					event.put(key, set.getValue());
				}
			}
		}
	}catch(Exception e){
	   logger.error("parserGrok_error", e);
	}
}
 
开发者ID:DTStack,项目名称:jlogstash-filter-plugin,代码行数:25,代码来源:JGrok.java

示例2: processLine

import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
void processLine(String line) {
    //executer.field("raw", line);
    //System.out.println(line);
    Match gm = grok.match(line);
    gm.captures();
    Map<String, Object> m = gm.toMap();
    Document document = new Document();
    for (Map.Entry<String, Object> entry : m.entrySet()) {
        Object value = entry.getValue();
        document.addField(entry.getKey(),String.valueOf(value));
    }

    if (!m.isEmpty()) {
        document.addField("filename", currentFileName);
        if (keepRaw) {
            document.addField("raw", line);
        }
        executer.document(document);
    }

}
 
开发者ID:tblsoft,项目名称:solr-cmd-utils,代码行数:22,代码来源:GrokReader.java

示例3: processLine

import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
void processLine(String line) {

        //executer.field("raw", line);


        System.out.println(line);
        Match gm = grok.match(line);

        gm.captures();
        Map<String, Object> m = gm.toMap();
        Document document = new Document();
        for (Map.Entry<String, Object> entry : m.entrySet()) {
            Object value = entry.getValue();
            document.addField(entry.getKey(),String.valueOf(value));
        }

        if (!m.isEmpty()) {
            document.addField("filename", currentFileName);
            if (keepRaw) {
                document.addField("raw", line);
            }
            executer.document(document);
        }

    }
 
开发者ID:tblsoft,项目名称:solr-cmd-utils,代码行数:26,代码来源:GCLogReader.java

示例4: processLine

import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
void processLine(String line) {
    //executer.field("raw", line);
    //System.out.println(line);
    Match gm = grok.match(line);
    gm.captures();
    Map<String, Object> m = gm.toMap();
    Document document = new Document();
    for (Map.Entry<String, Object> entry : m.entrySet()) {
        Object value = entry.getValue();
        document.addField(entry.getKey(),String.valueOf(value));
    }

    /*
    if (!m.isEmpty()) {
        document.addField("filename", currentFileName);
        if (keepRaw) {
            document.addField("raw", line);
        }
    }
    executer.document(document);
    */
}
 
开发者ID:tblsoft,项目名称:solr-cmd-utils,代码行数:23,代码来源:GrokFilter.java

示例5: evaluate

import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
@Override
public GrokResult evaluate(FunctionArgs args, EvaluationContext context) {
    final String value = valueParam.required(args, context);
    final String pattern = patternParam.required(args, context);
    final boolean onlyNamedCaptures = namedOnly.optional(args, context).orElse(false);

    if (value == null || pattern == null) {
        return null;
    }

    final Grok grok = grokPatternRegistry.cachedGrokForPattern(pattern, onlyNamedCaptures);

    final Match match = grok.match(value);
    match.captures();
    return new GrokResult(match.toMap());
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:17,代码来源:GrokMatch.java

示例6: parseLine

import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
public Map<String, Object> parseLine(String fileName, int lineNum, String line) throws Exception {
  if (line == null || line.isEmpty())
    return null;

  Match gm = grok.match(line);
  gm.captures();

  if (gm.isNull())
    return null;

  Map<String,Object> grokMap = gm.toMap();

  // add the ISO-8601 timestamp field if was requested in the config
  if (timestampFieldName != null) {
    Date timestamp = getLogDate(grokMap);
    if (timestamp != null) {
      grokMap.put(timestampFieldName, iso8601.get().format(timestamp));
    }
  }

  return grokMap;
}
 
开发者ID:lucidworks,项目名称:storm-solr,代码行数:23,代码来源:GrokLogLineParser.java

示例7: validateGrokStatement

import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
@Override
public GrokValidation validateGrokStatement(GrokValidation grokValidation) throws RestException {
    Map<String, Object> results;
    try {
        if (grokValidation.getPatternLabel() == null) {
          throw new RestException("Pattern label is required");
        }
        if (Strings.isEmpty(grokValidation.getStatement())) {
          throw new RestException("Grok statement is required");
        }
        Grok grok = new Grok();
        grok.addPatternFromReader(new InputStreamReader(getClass().getResourceAsStream("/patterns/common")));
        grok.addPatternFromReader(new StringReader(grokValidation.getStatement()));
        String grokPattern = "%{" + grokValidation.getPatternLabel() + "}";
        grok.compile(grokPattern);
        Match gm = grok.match(grokValidation.getSampleData());
        gm.captures();
        results = gm.toMap();
        results.remove(grokValidation.getPatternLabel());
    } catch (Exception e) {
        throw new RestException(e);
    }
    grokValidation.setResults(results);
    return grokValidation;
}
 
开发者ID:apache,项目名称:metron,代码行数:26,代码来源:GrokServiceImpl.java

示例8: parseLine

import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
public Map<String, Object> parseLine(String fileName, int lineNum, String line) throws Exception {
  if (line == null || line.isEmpty())
    return null;

  Match gm = grok.match(line);
  gm.captures();

  if (gm.isNull()){
    if (unmatchedLineName != null && unmatchedLineName.isEmpty() == false){
      return Collections.<String, Object>singletonMap(unmatchedLineName, line);
    } else {
      return null;
    }
  }

  Map<String,Object> grokMap = gm.toMap();

  // add the ISO-8601 timestamp field if was requested in the config
  if (timestampFieldName != null) {
    Date timestamp = getLogDate(grokMap);
    if (timestamp != null) {
      grokMap.put(timestampFieldName, iso8601.get().format(timestamp));
    }
  }

  return grokMap;
}
 
开发者ID:lucidworks,项目名称:fusion-log-indexer,代码行数:28,代码来源:GrokLogLineParser.java

示例9: parse

import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
public Map<String, Object> parse(final String input) {
    final Match m = instance.match(input);

    if (m == Match.EMPTY) {
        return ImmutableMap.of();
    }

    m.captures();
    return m.toMap();
}
 
开发者ID:spotify,项目名称:heroic,代码行数:11,代码来源:GrokProcessor.java

示例10: getCurrentRecord

import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
public Map<String, Object> getCurrentRecord() {
    Match gm = grok.match(currentLine);
    gm.captures();
    if (gm.isNull()) {
        throw new GrokRecordValidateException("Couldn't parse line");
    }
    return gm.toMap();
}
 
开发者ID:arielnetworks,项目名称:embulk-parser-grok,代码行数:9,代码来源:GrokRecordIterator.java

示例11: getMap

import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
private Map<String, Object> getMap(String pattern, String text)
		throws GrokException {

	Grok g = grokMap.get(pattern);
	if (g != null) {
		Match gm = g.match(text);
		gm.captures();
		return gm.toMap();
	} else {
		return new HashMap<String, Object>();
	}

}
 
开发者ID:OpenSOC,项目名称:opensoc-streaming,代码行数:14,代码来源:GrokAsaParser.java

示例12: afterAllLinesRead

import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
@Override
public void afterAllLinesRead(Map<String, Object> mutable) {
  mutable.remove("SECOND");
  mutable.remove("MONTHNUM");
  mutable.remove("YEAR");
  mutable.remove("MONTHDAY");
  String pat = grok.getOriginalGrokPattern();
  mutable.remove(pat.substring(2, pat.length() - 1));

  // try to break out the mdc context if available
  String mdc = (String)mutable.get("mdc_s");
  if (mdc != null)
    unpackMdcInfo(mdc, mutable);

  // if this message looks like a request message (such as a query), try to parse out the additional fields
  String category = (String)mutable.get("category_s");
  String message = (String)mutable.get(logMessageFieldName);
  if (("o.a.s.c.S.Request".equals(category) || "org.apache.solr.core.SolrCore".equals(category)) && message != null) {
    // see if this request line matches the Solr request format to parse out additional fields like query params

    String requestPart = message.replaceAll("\\s+"," ").trim();
    Match requestMatch = requestGrok.match(requestPart);
    requestMatch.captures();
    if (!requestMatch.isNull()) {
      Map<String,Object> requestMap = requestMatch.toMap();
      requestMap.remove("logmessage");
      requestMap.remove("BASE10NUM");
      String rpat = requestGrok.getOriginalGrokPattern();
      requestMap.remove(rpat.substring(2,rpat.length()-1));
      mutable.putAll(requestMap);

      if (parseParams) {
        String params_s = (String)requestMap.get("params_s");
        if (params_s != null) {
          String[] pairs = params_s.split("&");
          for (String nvp : pairs) {
            int eqAt = nvp.indexOf("=");
            if (eqAt != -1) {
              String key = nvp.substring(0,eqAt);
              String value = nvp.substring(eqAt+1);
              if (!"_".equals(key)) {
                if (!key.endsWith("_s")) {
                  key += "_s";
                }
                mutable.put(key, value);
              }
            }
          }
        }
      }
    }
  }
}
 
开发者ID:lucidworks,项目名称:fusion-log-indexer,代码行数:54,代码来源:SolrLogParser.java

示例13: apply

import oi.thekraken.grok.api.Match; //导入方法依赖的package包/类
private Map<String, Object> apply(final Grok grok, final String line) {
    final Match gm = grok.match(line);
    gm.captures();
    return gm.toMap();
}
 
开发者ID:sgoeschl,项目名称:access-log-sla-report,代码行数:6,代码来源:SitCatalinaAccessLogGrokTest.java


注:本文中的oi.thekraken.grok.api.Match.toMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。