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


Java AlertCondition类代码示例

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


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

示例1: call

import org.graylog2.plugin.alarms.AlertCondition; //导入依赖的package包/类
@Override
public void call (final Stream stream, final AlertCondition.CheckResult result) throws AlarmCallbackException {
  
  call (new JiraIssueClient (
      configuration.getString(CK_JIRA_PROJECT_KEY),
      buildJIRATitle (stream, result),
      buildDescription (stream, result),
      configuration.getString(CK_JIRA_LABELS),
      configuration.getString(CK_JIRA_ISSUE_TYPE),
      configuration.getString(CK_JIRA_COMPONENTS),
      configuration.getString(CK_JIRA_PRIORITY),
      configuration.getString(CK_JIRA_INSTANCE_URL),
      configuration.getString(CK_JIRA_USERNAME),
      configuration.getString(CK_JIRA_PASSWORD),
      configuration.getString(CK_JIRA_MD5_FILTER_QUERY),
      configuration.getString(CK_JIRA_MD5_CUSTOM_FIELD),
      buildJIRAGraylogMapping(stream, result),
      getJIRAMessageDigest (stream, result)), stream, result);
}
 
开发者ID:magicdude4eva,项目名称:graylog-jira-alarmcallback,代码行数:20,代码来源:JiraAlarmCallback.java

示例2: trigger

import org.graylog2.plugin.alarms.AlertCondition; //导入依赖的package包/类
public void trigger (final Stream stream, final AlertCondition.CheckResult checkResult) throws AlarmCallbackException {

    try {
      BasicCredentials creds = new BasicCredentials (JIRAUserName, JIRAPassword);
  
      jiraClient = new JiraClient(JIRAServerURL, creds);
  
      if (isDuplicateJiraIssue() == false) {
        createJIRAIssue();
      }
    } catch (Throwable ex) {
      LOG.error("Error in trigger function" + ex.getMessage() + (ex.getCause() != null ? ", Cause=" + ex.getCause().getMessage() : ""), ex);
      throw ex;
    }
    
 }
 
开发者ID:magicdude4eva,项目名称:graylog-jira-alarmcallback,代码行数:17,代码来源:JiraIssueClient.java

示例3: call

import org.graylog2.plugin.alarms.AlertCondition; //导入依赖的package包/类
@Override
public void call(Stream stream, AlertCondition.CheckResult result) throws AlarmCallbackException {
    final JiraClient client = new JiraClient(
            configuration.getString(CK_INSTANCE_URL),
            configuration.getString(CK_USERNAME),
            configuration.getString(CK_PASSWORD)
    );

    JiraIssue jiraIssue = new JiraIssue(
            configuration.getString(CK_PROJECT_KEY),
            configuration.getString(CK_LABELS),
            configuration.getString(CK_ISSUE_TYPE),
            configuration.getString(CK_COMPONENTS),
            configuration.getString(CK_PRIORITY),
            buildTitle(stream),
            buildDescription(stream, result, configuration)
    );
    try {
        client.send(jiraIssue);
    } catch (JiraClient.JiraClientException e) {
        throw new RuntimeException(e.getMessage());
    }
}
 
开发者ID:tjackiw,项目名称:graylog-plugin-jira,代码行数:24,代码来源:JiraAlarmCallback.java

示例4: testCallSucceedsWithSimpleJob

import org.graylog2.plugin.alarms.AlertCondition; //导入依赖的package包/类
@Test
public void testCallSucceedsWithSimpleJob() throws Exception {
    final Stream mockStream = mock(Stream.class);
    final AlertCondition.CheckResult checkResult = new AbstractAlertCondition.NegativeCheckResult(
            new DummyAlertCondition(
                    mockStream,
                    "id",
                    new DateTime(2017, 3, 20, 0, 0, DateTimeZone.UTC),
                    "user",
                    Collections.emptyMap())
    );

    final Configuration configuration = new Configuration(VALID_CONFIG_SOURCE);
    configuration.setString("api_token", token);
    configuration.setString("job_id", "804f107a-cafe-babe-0000-deadbeef0000");

    alarmCallback.initialize(configuration);
    alarmCallback.checkConfiguration();
    alarmCallback.call(mockStream, checkResult);
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-rundeck,代码行数:21,代码来源:RundeckAlarmCallbackIT.java

示例5: testCallFailsWithDisabledJob

import org.graylog2.plugin.alarms.AlertCondition; //导入依赖的package包/类
@Test
public void testCallFailsWithDisabledJob() throws Exception {
    final Stream mockStream = mock(Stream.class);
    final AlertCondition.CheckResult checkResult = new AbstractAlertCondition.NegativeCheckResult(
            new DummyAlertCondition(
                    mockStream,
                    "id",
                    new DateTime(2017, 3, 20, 0, 0, DateTimeZone.UTC),
                    "user",
                    Collections.emptyMap())
    );

    final Configuration configuration = new Configuration(VALID_CONFIG_SOURCE);
    configuration.setString("api_token", token);
    configuration.setString("job_id", "804f107a-cafe-babe-0000-deadbeef0001");

    expectedException.expect(AlarmCallbackException.class);
    expectedException.expectMessage("Failed to send alarm to Rundeck");

    alarmCallback.initialize(configuration);
    alarmCallback.checkConfiguration();
    alarmCallback.call(mockStream, checkResult);
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-rundeck,代码行数:24,代码来源:RundeckAlarmCallbackIT.java

示例6: testCallSucceedsWithFailingJob

import org.graylog2.plugin.alarms.AlertCondition; //导入依赖的package包/类
@Test
public void testCallSucceedsWithFailingJob() throws Exception {
    final Stream mockStream = mock(Stream.class);
    final AlertCondition.CheckResult checkResult = new AbstractAlertCondition.NegativeCheckResult(
            new DummyAlertCondition(
                    mockStream,
                    "id",
                    new DateTime(2017, 3, 20, 0, 0, DateTimeZone.UTC),
                    "user",
                    Collections.emptyMap())
    );

    final Configuration configuration = new Configuration(VALID_CONFIG_SOURCE);
    configuration.setString("api_token", token);
    configuration.setString("job_id", "804f107a-cafe-babe-0000-deadbeef0002");

    alarmCallback.initialize(configuration);
    alarmCallback.checkConfiguration();
    alarmCallback.call(mockStream, checkResult);
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-rundeck,代码行数:21,代码来源:RundeckAlarmCallbackIT.java

示例7: testCallSucceedsWithParameterizedJob

import org.graylog2.plugin.alarms.AlertCondition; //导入依赖的package包/类
@Test
public void testCallSucceedsWithParameterizedJob() throws Exception {
    final Stream mockStream = mock(Stream.class);
    final AlertCondition.CheckResult checkResult = new AbstractAlertCondition.NegativeCheckResult(
            new DummyAlertCondition(
                    mockStream,
                    "id",
                    new DateTime(2017, 3, 20, 0, 0, DateTimeZone.UTC),
                    "user",
                    Collections.emptyMap())
    );

    final Configuration configuration = new Configuration(VALID_CONFIG_SOURCE);
    configuration.setString("api_token", token);
    configuration.setString("job_id", "804f107a-cafe-babe-0000-deadbeef0003");
    configuration.setString("args", "custom-arg:Test");

    alarmCallback.initialize(configuration);
    alarmCallback.checkConfiguration();
    alarmCallback.call(mockStream, checkResult);
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-rundeck,代码行数:22,代码来源:RundeckAlarmCallbackIT.java

示例8: testCallFailsWithParameterizedJobWithoutParameters

import org.graylog2.plugin.alarms.AlertCondition; //导入依赖的package包/类
@Test
public void testCallFailsWithParameterizedJobWithoutParameters() throws Exception {
    final Stream mockStream = mock(Stream.class);
    final AlertCondition.CheckResult checkResult = new AbstractAlertCondition.NegativeCheckResult(
            new DummyAlertCondition(
                    mockStream,
                    "id",
                    new DateTime(2017, 3, 20, 0, 0, DateTimeZone.UTC),
                    "user",
                    Collections.emptyMap())
    );

    final Configuration configuration = new Configuration(VALID_CONFIG_SOURCE);
    configuration.setString("api_token", token);
    configuration.setString("job_id", "804f107a-cafe-babe-0000-deadbeef0003");

    expectedException.expect(AlarmCallbackException.class);
    expectedException.expectMessage("Failed to send alarm to Rundeck");

    alarmCallback.initialize(configuration);
    alarmCallback.checkConfiguration();
    alarmCallback.call(mockStream, checkResult);
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-rundeck,代码行数:24,代码来源:RundeckAlarmCallbackIT.java

示例9: testCallFailsWithUnknownJob

import org.graylog2.plugin.alarms.AlertCondition; //导入依赖的package包/类
@Test
public void testCallFailsWithUnknownJob() throws Exception {
    final Stream mockStream = mock(Stream.class);
    final AlertCondition.CheckResult checkResult = new AbstractAlertCondition.NegativeCheckResult(
            new DummyAlertCondition(
                    mockStream,
                    "id",
                    new DateTime(2017, 3, 20, 0, 0, DateTimeZone.UTC),
                    "user",
                    Collections.emptyMap())
    );

    final Configuration configuration = new Configuration(VALID_CONFIG_SOURCE);
    configuration.setString("api_token", token);
    configuration.setString("job_id", "unknown");

    expectedException.expect(AlarmCallbackException.class);
    expectedException.expectMessage("Failed to send alarm to Rundeck");

    alarmCallback.initialize(configuration);
    alarmCallback.checkConfiguration();
    alarmCallback.call(mockStream, checkResult);
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-rundeck,代码行数:24,代码来源:RundeckAlarmCallbackIT.java

示例10: buildFullMessageBody

import org.graylog2.plugin.alarms.AlertCondition; //导入依赖的package包/类
private String buildFullMessageBody(Stream stream, AlertCondition.CheckResult result) {
    String graylogUri = configuration.getString(SlackConfiguration.CK_GRAYLOG2_URL);
    boolean notifyChannel = configuration.getBoolean(SlackConfiguration.CK_NOTIFY_CHANNEL);

    String titleLink;
    if (!isNullOrEmpty(graylogUri)) {
        titleLink = "<" + buildStreamLink(graylogUri, stream) + "|" + stream.getTitle() + ">";
    } else {
        titleLink = "_" + stream.getTitle() + "_";
    }

    // Build custom message
    StringBuilder message = new StringBuilder(result.getResultDescription()).append("\n");
    String template = configuration.getString(SlackConfiguration.CK_CUSTOM_MESSAGE);
    if (!isNullOrEmpty(template)) {
        String customMessage = buildCustomMessage(stream, result, template);
        message.append("\n").append(customMessage);
    }

    String audience = notifyChannel ? "@channel " : "";
    return String.format("%s*Alert for Graylog stream %s*:\n> %s",
            audience, titleLink, message.toString());
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-slack,代码行数:24,代码来源:SlackAlarmCallback.java

示例11: getModel

import org.graylog2.plugin.alarms.AlertCondition; //导入依赖的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

示例12: buildJIRAGraylogMapping

import org.graylog2.plugin.alarms.AlertCondition; //导入依赖的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

示例13: buildDescription

import org.graylog2.plugin.alarms.AlertCondition; //导入依赖的package包/类
protected String buildDescription(Stream stream, AlertCondition.CheckResult checkResult, Configuration configuration) {
    StringBuilder sb = new StringBuilder();

    sb.append(checkResult.getResultDescription());
    sb.append("\n\n");
    sb.append("*Date:* ").append("\n").append(Tools.iso8601().toString()).append("\n\n");
    sb.append("*Stream ID:* ").append("\n").append(stream.getId()).append("\n\n");
    sb.append("*Stream title:* ").append("\n").append(stream.getTitle()).append("\n\n");
    sb.append("*Stream URL:* ").append("\n").append(buildStreamURL(configuration.getString(CK_GRAYLOG_URL), stream)).append("\n\n");
    sb.append("*Stream rules:* ").append("\n").append(buildStreamRules(stream)).append("\n\n");
    sb.append("*Alert triggered at:* ").append("\n").append(checkResult.getTriggeredAt()).append("\n\n");
    sb.append("*Triggered condition:* ").append("\n").append(checkResult.getTriggeredCondition()).append("\n\n");

    return sb.toString();
}
 
开发者ID:tjackiw,项目名称:graylog-plugin-jira,代码行数:16,代码来源:JiraPluginBase.java

示例14: call

import org.graylog2.plugin.alarms.AlertCondition; //导入依赖的package包/类
@Override
public void call(Stream stream, AlertCondition.CheckResult cr) throws AlarmCallbackException {
    try {
        sendAlert(stream, cr);
    } catch (Exception e) {
        LOG.error("Could not send alert to Alertflex (AlarmCallbackException)", e);
    }
}
 
开发者ID:olegzhr,项目名称:GraylogPlugin,代码行数:9,代码来源:AlertflexAlarmCallback.java

示例15: formatAlarmNotification

import org.graylog2.plugin.alarms.AlertCondition; //导入依赖的package包/类
private String formatAlarmNotification(final Stream stream, final AlertCondition.CheckResult result) {
    return "Graylog alert for stream <" + stream.getTitle() + ">\n\n"
            + "Date: " + result.getTriggeredAt() + "\n"
            + "Stream ID: " + stream.getId() + "\n"
            + "Stream title: " + stream.getTitle() + "\n"
            + "Triggered condition: " + result.getTriggeredCondition() + "\n";
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-jabber,代码行数:8,代码来源:JabberAlarmCallbackFormatter.java


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