本文整理汇总了Java中org.graylog2.plugin.alarms.AlertCondition.CheckResult方法的典型用法代码示例。如果您正苦于以下问题:Java AlertCondition.CheckResult方法的具体用法?Java AlertCondition.CheckResult怎么用?Java AlertCondition.CheckResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.graylog2.plugin.alarms.AlertCondition
的用法示例。
在下文中一共展示了AlertCondition.CheckResult方法的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);
}
示例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;
}
}
示例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());
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
}
示例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";
}