use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.alert.FeatureGroupAlert 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.persistence.entity.featurestore.featuregroup.datavalidation.alert.FeatureGroupAlert in project hopsworks by logicalclocks.
the class FeatureGroupAlertResource method createAlert.
private FeatureGroupAlertDTO createAlert(PostableFeatureGroupAlerts dto, UriInfo uriInfo, ResourceRequest resourceRequest) throws FeaturestoreException {
validate(dto);
FeatureGroupAlert featureGroupAlert = new FeatureGroupAlert();
featureGroupAlert.setStatus(dto.getStatus());
featureGroupAlert.setSeverity(dto.getSeverity());
featureGroupAlert.setCreated(new Date());
featureGroupAlert.setFeatureGroup(this.featuregroup);
featureGroupAlert.setReceiver(getReceiver(dto.getReceiver()));
featureGroupAlert.setAlertType(alertController.getAlertType(featureGroupAlert.getReceiver()));
createRoute(featureGroupAlert);
featureGroupAlertFacade.save(featureGroupAlert);
featureGroupAlert = featureGroupAlertFacade.findByFeatureGroupAndStatus(this.featuregroup, dto.getStatus());
return featureGroupAlertBuilder.buildItems(uriInfo, resourceRequest, featureGroupAlert);
}
use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.alert.FeatureGroupAlert in project hopsworks by logicalclocks.
the class FeatureGroupAlertResource method createOrUpdate.
@PUT
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Update a feature group alert.", response = FeatureGroupAlertDTO.class)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response createOrUpdate(@PathParam("id") Integer id, FeatureGroupAlertDTO dto, @Context UriInfo uriInfo, @Context SecurityContext sc) throws FeaturestoreException {
FeatureGroupAlert featureGroupAlert = featureGroupAlertFacade.findByFeatureGroupAndId(this.featuregroup, id);
if (featureGroupAlert == null) {
throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.ALERT_NOT_FOUND, Level.FINE);
}
if (dto == null) {
throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.ALERT_ILLEGAL_ARGUMENT, Level.FINE, "No payload.");
}
if (dto.getStatus() != null) {
if (!dto.getStatus().equals(featureGroupAlert.getStatus()) && featureGroupAlertFacade.findByFeatureGroupAndStatus(this.featuregroup, dto.getStatus()) != null) {
throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.ALERT_ALREADY_EXISTS, Level.FINE, "Feature Group Alert with FeatureGroupName=" + this.featuregroup.getName() + " status=" + dto.getStatus() + " already exists.");
}
featureGroupAlert.setStatus(dto.getStatus());
}
if (dto.getSeverity() != null) {
featureGroupAlert.setSeverity(dto.getSeverity());
}
if (!featureGroupAlert.getReceiver().getName().equals(dto.getReceiver())) {
deleteRoute(featureGroupAlert);
featureGroupAlert.setReceiver(getReceiver(dto.getReceiver()));
createRoute(featureGroupAlert);
}
featureGroupAlert.setAlertType(alertController.getAlertType(featureGroupAlert.getReceiver()));
featureGroupAlert = featureGroupAlertFacade.update(featureGroupAlert);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.ALERTS);
dto = featureGroupAlertBuilder.build(uriInfo, resourceRequest, featureGroupAlert);
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.alert.FeatureGroupAlert in project hopsworks by logicalclocks.
the class AlertManagerConfiguration method getRoutesToAdd.
private List<Route> getRoutesToAdd(AlertReceiver alertReceiver, List<Route> routes) {
Collection<JobAlert> jobAlerts = alertReceiver.getJobAlertCollection();
Collection<FeatureGroupAlert> featureGroupAlerts = alertReceiver.getFeatureGroupAlertCollection();
Collection<ProjectServiceAlert> projectServiceAlerts = alertReceiver.getProjectServiceAlertCollection();
List<Route> routesToAdd = new ArrayList<>();
for (JobAlert jobAlert : jobAlerts) {
Route route = jobAlert.getAlertType().isGlobal() ? ConfigUtil.getRoute(jobAlert.getAlertType()) : ConfigUtil.getRoute(jobAlert);
if (!routes.contains(route) && !routesToAdd.contains(route)) {
routesToAdd.add(route);
}
}
for (FeatureGroupAlert featureGroupAlert : featureGroupAlerts) {
Route route = featureGroupAlert.getAlertType().isGlobal() ? ConfigUtil.getRoute(featureGroupAlert.getAlertType()) : ConfigUtil.getRoute(featureGroupAlert);
if (!routes.contains(route) && !routesToAdd.contains(route)) {
routesToAdd.add(route);
}
}
for (ProjectServiceAlert projectServiceAlert : projectServiceAlerts) {
Route route = projectServiceAlert.getAlertType().isGlobal() ? ConfigUtil.getRoute(projectServiceAlert.getAlertType()) : ConfigUtil.getRoute(projectServiceAlert);
if (!routes.contains(route) && !routesToAdd.contains(route)) {
routesToAdd.add(route);
}
}
return routesToAdd;
}
use of io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.alert.FeatureGroupAlert in project hopsworks by logicalclocks.
the class TestAlertManagerConfigTimer method createAlertReceiver.
private AlertReceiver createAlertReceiver(Integer id, Receiver receiver, AlertType alertType) throws JsonProcessingException {
AlertReceiver alertReceiver = new AlertReceiver();
alertReceiver.setId(id);
alertReceiver.setName(receiver.getName());
alertReceiver.setConfig(toJson(receiver));
Project project = new Project("project1");
Jobs job = new Jobs();
job.setProject(project);
job.setName("job1");
Featurestore featurestore = new Featurestore();
featurestore.setProject(project);
Featuregroup featuregroup = new Featuregroup();
featuregroup.setFeaturestore(featurestore);
featuregroup.setName("fg1");
List<JobAlert> jobAlerts = new ArrayList<>();
jobAlerts.add(new JobAlert(random.nextInt(1000), JobAlertStatus.FAILED, alertType, AlertSeverity.CRITICAL, new Date(), job, alertReceiver));
jobAlerts.add(new JobAlert(random.nextInt(1000), JobAlertStatus.KILLED, alertType, AlertSeverity.WARNING, new Date(), job, alertReceiver));
alertReceiver.setJobAlertCollection(jobAlerts);
List<FeatureGroupAlert> featureGroupAlerts = new ArrayList<>();
featureGroupAlerts.add(new FeatureGroupAlert(random.nextInt(1000), ValidationRuleAlertStatus.FAILURE, alertType, AlertSeverity.CRITICAL, new Date(), featuregroup, alertReceiver));
featureGroupAlerts.add(new FeatureGroupAlert(random.nextInt(1000), ValidationRuleAlertStatus.WARNING, alertType, AlertSeverity.WARNING, new Date(), featuregroup, alertReceiver));
alertReceiver.setFeatureGroupAlertCollection(featureGroupAlerts);
List<ProjectServiceAlert> projectServiceAlerts = new ArrayList<>();
projectServiceAlerts.add(new ProjectServiceAlert(random.nextInt(1000), ProjectServiceEnum.FEATURESTORE, ProjectServiceAlertStatus.VALIDATION_FAILURE, alertType, AlertSeverity.WARNING, new Date(), project, alertReceiver));
projectServiceAlerts.add(new ProjectServiceAlert(random.nextInt(1000), ProjectServiceEnum.JOBS, ProjectServiceAlertStatus.JOB_FAILED, alertType, AlertSeverity.WARNING, new Date(), project, alertReceiver));
alertReceiver.setProjectServiceAlertCollection(projectServiceAlerts);
return alertReceiver;
}
Aggregations