• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MessageSummary类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.graylog2.plugin.MessageSummary的典型用法代码示例。如果您正苦于以下问题:Java MessageSummary类的具体用法?Java MessageSummary怎么用?Java MessageSummary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MessageSummary类属于org.graylog2.plugin包,在下文中一共展示了MessageSummary类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getModel

import org.graylog2.plugin.MessageSummary; //导入依赖的package包/类
private Map<String, Object> getModel(AlertCondition condition, AlertCondition.CheckResult alert) throws AlarmCallbackException {
    Stream stream = condition.getStream();
    List<Message> messages = new ArrayList<>();
    for (MessageSummary messageSummary : alert.getMatchingMessages()) {
        messages.add(messageSummary.getRawMessage());
    }
    HashMap<String, Object> model = new HashMap<>();
    model.put("stream", stream);
    model.put("check_result", alert);
    if (graylogBaseUrl != null) {
        model.put("stream_url", buildStreamDetailsURL(graylogBaseUrl, alert, stream));
    }
    model.put("backlog", messages);
    model.put("backlog_size", messages.size());
    return model;
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-hipchat,代码行数:17,代码来源:HipChatTrigger.java


示例2: buildJIRAGraylogMapping

import org.graylog2.plugin.MessageSummary; //导入依赖的package包/类
/**
 * Build up a list of JIRA/Graylog field mappings
 * @param stream
 * @param result
 * @return
 */
private Map<String, String> buildJIRAGraylogMapping (final Stream stream, final AlertCondition.CheckResult result) {

  Map<String, String> JIRAFieldMapping = new HashMap<String, String>();
  
  if (configuration.stringIsSet(CK_JIRA_GRAYLOG_MAPPING) && !configuration.getString(CK_JIRA_GRAYLOG_MAPPING).equals("null") && !result.getMatchingMessages().isEmpty()) {
    try {
      // get fields from last message only
      MessageSummary lastMessage = result.getMatchingMessages().get(0);
      
      String[] mappingPairs = StringUtils.split(configuration.getString(CK_JIRA_GRAYLOG_MAPPING), ',');
      
      if (mappingPairs != null && mappingPairs.length > 0) {
        for (String mappingString : mappingPairs) {
            String[] mapping = StringUtils.split(mappingString, '=');
            
            if (mapping.length == 2 && lastMessage.hasField(mapping[0])) {
              Object test = lastMessage.getField(mapping[0]);
              JIRAFieldMapping.put(mapping[1], test.toString());
            }
        }
      }
    } catch (Exception ex) {
      ; // can not do anything - we skip
      LOG.error("Error in generating JIRA/Graylog mapping " + ex.getMessage());
    }
  }
  
  return JIRAFieldMapping;
}
 
开发者ID:magicdude4eva,项目名称:graylog-jira-alarmcallback,代码行数:36,代码来源:JiraAlarmCallback.java


示例3: getAlarmBacklog

import org.graylog2.plugin.MessageSummary; //导入依赖的package包/类
private List<Message> getAlarmBacklog(AlertCondition.CheckResult result) {
    final AlertCondition alertCondition = result.getTriggeredCondition();
    final List<MessageSummary> matchingMessages = result.getMatchingMessages();
    final int effectiveBacklogSize = Math.min(alertCondition.getBacklog(), matchingMessages.size());

    if (effectiveBacklogSize == 0) return Collections.emptyList();
    final List<MessageSummary> backlogSummaries = matchingMessages.subList(0, effectiveBacklogSize);
    final List<Message> backlog = Lists.newArrayListWithCapacity(effectiveBacklogSize);
    for (MessageSummary messageSummary : backlogSummaries) {
        backlog.add(messageSummary.getRawMessage());
    }

    return backlog;
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-slack,代码行数:15,代码来源:SlackAlarmCallback.java


示例4: runCheck

import org.graylog2.plugin.MessageSummary; //导入依赖的package包/类
@Override
  public CheckResult runCheck() {        
      String filter = "streams:" + stream.getId();
      Integer backlogSize = getBacklog();
      boolean backlogEnabled = false;
      int searchLimit = 1;

      if(backlogSize != null && backlogSize > 0) {
          backlogEnabled = true;
          searchLimit = backlogSize;
      }

      SearchResult result = searches.search(
    query,
    filter,
    AbsoluteRange.create(Tools.nowUTC().minus(Minutes.minutes(backtime)).minus(Minutes.minutes(staytime)), Tools.nowUTC().minus(Minutes.minutes(backtime))),
    searchLimit,
    0,
    new Sorting(Message.FIELD_TIMESTAMP, Sorting.Direction.DESC)
);

final List<MessageSummary> summaries;
if (backlogEnabled) {
    summaries = Lists.newArrayListWithCapacity(result.getResults().size());
    for (ResultMessage resultMessage : result.getResults()) {
        final Message msg = resultMessage.getMessage();
        summaries.add(new MessageSummary(resultMessage.getIndex(), msg));
    }
} else {
    summaries = Collections.emptyList();
}

final long count = result.getTotalResults();

final String resultDescription = "Stream received messages matching <" + query + "> "
    + "(Current grace time: " + grace + " minutes)";

if (count > 0) {
    LOG.debug("Alert check <{}> found [{}] messages.", id, count);
    return new CheckResult(true, this, resultDescription, Tools.nowUTC(), summaries);
} else {
    LOG.debug("Alert check <{}> returned no results.", id);
    return new NegativeCheckResult();
}
  }
 
开发者ID:alcampos,项目名称:graylog-plugin-alert-condition-delorean,代码行数:46,代码来源:DeloreanAlertCondition.java


示例5: buildJIRATitle

import org.graylog2.plugin.MessageSummary; //导入依赖的package包/类
/**
 * Build the JIRA issue title
 * @param stream
 * @param result
 * @return
 */
private String buildJIRATitle (final Stream stream, final AlertCondition.CheckResult result) {

  StringBuilder sb = new StringBuilder();
  
  try {
    if (!result.getMatchingMessages().isEmpty()) {
      // get fields from last message only
      MessageSummary lastMessage = result.getMatchingMessages().get(0);
      
      Map<String, Object> lastMessageFields = lastMessage.getFields();
      
      String strTitle = "[Alert] Graylog alert for stream: " + stream.getTitle();

      if (configuration.stringIsSet(CK_JIRA_TITLE_TEMPLATE) && !configuration.getString(CK_JIRA_TITLE_TEMPLATE).equals("null")) {
        strTitle = configuration.getString(CK_JIRA_TITLE_TEMPLATE);
      }
      
      strTitle = strTitle.replace("[LAST_MESSAGE.source]", lastMessage.getSource());
      
      for (Map.Entry<String, Object> arg : lastMessageFields.entrySet()) {
        strTitle = strTitle.replace("[LAST_MESSAGE." + arg.getKey() + "]", arg.getValue().toString());
      }
      
      if (configuration.stringIsSet(CK_MESSAGE_REGEX) && !configuration.getString(CK_MESSAGE_REGEX).equals("null")) {
        Matcher matcher = Pattern.compile(configuration.getString(CK_MESSAGE_REGEX)).matcher(lastMessage.getMessage());
        
        if (matcher.find()) {
          if (configuration.stringIsSet(CK_JIRA_TITLE_TEMPLATE) && !configuration.getString(CK_JIRA_TITLE_TEMPLATE).equals("null")) {
            strTitle = strTitle.replace("[MESSAGE_REGEX]", matcher.group());
          } else {
            strTitle = "[Graylog] " + matcher.group();
          }
        }
      }
      
      // We regex template fields which have not been replaced
      strTitle = strTitle.replaceAll("\\[LAST_MESSAGE\\.[^\\]]*\\]", "");
      
      sb.append(strTitle);
    }
  } catch (Exception ex) {
    ; // can not do anything - we skip
    LOG.error("Error in building title: " + ex.getMessage());
  }
  
  if (sb.length() == 0) {
    sb.append("[Alert] Graylog alert for stream: ").append(stream.getTitle());
  }
  
  return sb.toString();
}
 
开发者ID:magicdude4eva,项目名称:graylog-jira-alarmcallback,代码行数:58,代码来源:JiraAlarmCallback.java


示例6: buildDescription

import org.graylog2.plugin.MessageSummary; //导入依赖的package包/类
/**
 * Build the JIRA description
 * @param stream
 * @param result
 * @return
 */
private String buildDescription (final Stream stream, final AlertCondition.CheckResult result) {

  String strMessage = CONST_JIRA_MESSAGE_TEMPLATE;
  
  if (configuration.stringIsSet(CK_JIRA_MESSAGE_TEMPLATE) &&
      !configuration.getString(CK_JIRA_MESSAGE_TEMPLATE).equals("null") &&
      !configuration.getString(CK_JIRA_MESSAGE_TEMPLATE).isEmpty()) {
    strMessage = configuration.getString(CK_JIRA_MESSAGE_TEMPLATE);
  }
  
  strMessage = StringEscapeUtils.unescapeJava(strMessage);
  
  // Get the last message
  if (!result.getMatchingMessages().isEmpty()) {
    // get fields from last message only
    MessageSummary lastMessage = result.getMatchingMessages().get(0);
    Map<String, Object> lastMessageFields = lastMessage.getFields();

    strMessage = strMessage.replace("[LAST_MESSAGE.message]", lastMessage.getMessage());
    strMessage = strMessage.replace("[LAST_MESSAGE.source]", lastMessage.getSource());
    
    for (Map.Entry<String, Object> arg : lastMessageFields.entrySet()) {
      strMessage = strMessage.replace("[LAST_MESSAGE." + arg.getKey() + "]", arg.getValue().toString());
    }
    
    // We regex template fields which have not been replaced
    strMessage = strMessage.replaceAll("\\[LAST_MESSAGE\\.[^\\]]*\\]", "");
  }

  // replace placeholders
  strMessage = strMessage.replace("[CALLBACK_DATE]", Tools.iso8601().toString());
  strMessage = strMessage.replace("[STREAM_ID]", stream.getId());
  strMessage = strMessage.replace("[STREAM_TITLE]", stream.getTitle());
  strMessage = strMessage.replace("[STREAM_URL]", buildStreamURL(configuration.getString(CK_GRAYLOG_URL), stream));
  strMessage = strMessage.replace("[STREAM_RULES]", buildStreamRules(stream));
  strMessage = strMessage.replace("[STREAM_RESULT]", result.getResultDescription());
  strMessage = strMessage.replace("[ALERT_TRIGGERED_AT]", result.getTriggeredAt().toString());
  strMessage = strMessage.replace("[ALERT_TRIGGERED_CONDITION]", result.getTriggeredCondition().toString());
  
  // create final string
  StringBuilder sb = new StringBuilder();
  sb.append("\n\n");
  sb.append(strMessage).append("\n\n");
  
  return sb.toString();
}
 
开发者ID:magicdude4eva,项目名称:graylog-jira-alarmcallback,代码行数:53,代码来源:JiraAlarmCallback.java



注:本文中的org.graylog2.plugin.MessageSummary类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Calc类代码示例发布时间:2022-05-23
下一篇:
Java VFileProperty类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap