use of io.hops.hopsworks.alerting.api.alert.dto.PostableAlert in project hopsworks by logicalclocks.
the class AlertController method sendFgTestAlert.
private List<Alert> sendFgTestAlert(Project project, AlertType alertType, AlertSeverity severity, FeatureGroupValidation.Status status, String fgName) throws AlertManagerUnreachableException, AlertManagerAccessControlException, AlertManagerResponseException, AlertManagerClientCreateException {
String testAlertFgName = Strings.isNullOrEmpty(fgName) ? Constants.TEST_ALERT_FG_NAME : fgName;
List<PostableAlert> postableAlerts = new ArrayList<>();
PostableAlert postableAlert = getPostableAlert(project.getName(), alertType, severity, status.getName(), getExpectationResult(status, new ArrayList<>()), Constants.TEST_ALERT_FG_ID, Constants.TEST_ALERT_FS_NAME, testAlertFgName, Constants.TEST_ALERT_FG_VERSION);
postableAlerts.add(postableAlert);
sendAlert(postableAlerts, project);
String fgFilter = Constants.FILTER_BY_FG_FORMAT.replace(Constants.FG_PLACE_HOLDER, testAlertFgName) + Constants.FILTER_BY_FG_ID_FORMAT.replace(Constants.FG_ID_PLACE_HOLDER, Constants.TEST_ALERT_FG_ID.toString());
return getAlerts(project, fgFilter);
}
use of io.hops.hopsworks.alerting.api.alert.dto.PostableAlert in project hopsworks by logicalclocks.
the class AlertController method sendJobTestAlert.
private List<Alert> sendJobTestAlert(Project project, AlertType alertType, AlertSeverity severity, String status, String jobName) throws AlertManagerUnreachableException, AlertManagerAccessControlException, AlertManagerResponseException, AlertManagerClientCreateException {
List<PostableAlert> postableAlerts = new ArrayList<>();
String testAlertJobName = Strings.isNullOrEmpty(jobName) ? Constants.TEST_ALERT_JOB_NAME : jobName;
PostableAlert postableAlert = getPostableAlert(project, alertType, severity, status, testAlertJobName, Constants.TEST_ALERT_EXECUTION_ID);
postableAlerts.add(postableAlert);
sendAlert(postableAlerts, project);
String jobFilter = Constants.FILTER_BY_JOB_FORMAT.replace(Constants.JOB_PLACE_HOLDER, testAlertJobName) + Constants.FILTER_BY_EXECUTION_FORMAT.replace(Constants.EXECUTION_ID_PLACE_HOLDER, Constants.TEST_ALERT_EXECUTION_ID.toString());
return getAlerts(project, jobFilter);
}
use of io.hops.hopsworks.alerting.api.alert.dto.PostableAlert in project hopsworks by logicalclocks.
the class AlertController method getPostableAlerts.
private List<PostableAlert> getPostableAlerts(Featuregroup featuregroup, List<ExpectationResult> results, FeatureGroupValidation.Status status) {
List<PostableAlert> postableAlerts = new ArrayList<>();
if (FeatureGroupValidation.Status.NONE.equals(status)) {
return postableAlerts;
}
if (featuregroup.getFeatureGroupAlerts() != null && !featuregroup.getFeatureGroupAlerts().isEmpty()) {
for (FeatureGroupAlert alert : featuregroup.getFeatureGroupAlerts()) {
if (alert.getStatus().equals(ValidationRuleAlertStatus.getStatus(status))) {
String name = featurestoreFacade.getHiveDbName(featuregroup.getFeaturestore().getHiveDbId());
PostableAlert postableAlert = getPostableAlert(featuregroup.getFeaturestore().getProject().getName(), alert.getAlertType(), alert.getSeverity(), alert.getStatus().getName(), getExpectationResult(status, results), featuregroup.getId(), name, featuregroup.getName(), featuregroup.getVersion());
postableAlerts.add(postableAlert);
}
}
} else if (featuregroup.getFeaturestore().getProject().getProjectServiceAlerts() != null && !featuregroup.getFeaturestore().getProject().getProjectServiceAlerts().isEmpty()) {
for (ProjectServiceAlert alert : featuregroup.getFeaturestore().getProject().getProjectServiceAlerts()) {
if (ProjectServiceEnum.FEATURESTORE.equals(alert.getService()) && alert.getStatus().equals(ProjectServiceAlertStatus.getStatus(status))) {
String name = featurestoreFacade.getHiveDbName(featuregroup.getFeaturestore().getHiveDbId());
PostableAlert postableAlert = getPostableAlert(featuregroup.getFeaturestore().getProject().getName(), alert.getAlertType(), alert.getSeverity(), alert.getStatus().getName(), getExpectationResult(status, results), featuregroup.getId(), name, featuregroup.getName(), featuregroup.getVersion());
postableAlerts.add(postableAlert);
}
}
}
return postableAlerts;
}
use of io.hops.hopsworks.alerting.api.alert.dto.PostableAlert in project hopsworks by logicalclocks.
the class AlertBuilder method build.
public PostableAlert build(PostableAlertDTO alert) {
PostableAlert dto = new PostableAlert();
dto.setEndsAt(alert.getEndsAt());
dto.setStartsAt(alert.getStartsAt());
dto.setLabels(alert.getLabels().stream().filter(entry -> entry.getKey() != null && entry.getValue() != null).collect(Collectors.toMap(Entry::getKey, Entry::getValue)));
dto.setAnnotations(alert.getAnnotations().stream().filter(entry -> entry.getKey() != null && entry.getValue() != null).collect(Collectors.toMap(Entry::getKey, Entry::getValue)));
dto.setGeneratorURL(alert.getGeneratorURL());
return dto;
}
use of io.hops.hopsworks.alerting.api.alert.dto.PostableAlert in project hopsworks by logicalclocks.
the class AlertController method getAlerts.
private List<PostableAlert> getAlerts(JobAlertStatus jobAlertStatus, ProjectServiceAlertStatus projectServiceAlertStatus, Execution execution) {
List<PostableAlert> postableAlerts = new ArrayList<>();
if (execution.getJob().getJobAlertCollection() != null && !execution.getJob().getJobAlertCollection().isEmpty()) {
for (JobAlert alert : execution.getJob().getJobAlertCollection()) {
if (alert.getStatus().equals(jobAlertStatus)) {
PostableAlert postableAlert = getPostableAlert(execution.getJob().getProject(), alert.getAlertType(), alert.getSeverity(), alert.getStatus().getName(), execution.getJob().getName(), execution.getId());
postableAlerts.add(postableAlert);
}
}
} else if (execution.getJob().getProject().getProjectServiceAlerts() != null && !execution.getJob().getProject().getProjectServiceAlerts().isEmpty()) {
for (ProjectServiceAlert alert : execution.getJob().getProject().getProjectServiceAlerts()) {
if (ProjectServiceEnum.JOBS.equals(alert.getService()) && alert.getStatus().equals(projectServiceAlertStatus)) {
PostableAlert postableAlert = getPostableAlert(execution.getJob().getProject(), alert.getAlertType(), alert.getSeverity(), alert.getStatus().getName(), execution.getJob().getName(), execution.getId());
postableAlerts.add(postableAlert);
}
}
}
return postableAlerts;
}
Aggregations