Search in sources :

Example 1 with FeatureGroupAlert

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;
}
Also used : FeatureGroupAlert(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.alert.FeatureGroupAlert) ArrayList(java.util.ArrayList) PostableAlert(io.hops.hopsworks.alerting.api.alert.dto.PostableAlert) ProjectServiceAlert(io.hops.hopsworks.persistence.entity.project.alert.ProjectServiceAlert)

Example 2 with FeatureGroupAlert

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);
}
Also used : FeatureGroupAlert(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.alert.FeatureGroupAlert) Date(java.util.Date)

Example 3 with 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();
}
Also used : FeatureGroupAlert(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.alert.FeatureGroupAlert) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles) PUT(javax.ws.rs.PUT)

Example 4 with FeatureGroupAlert

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;
}
Also used : FeatureGroupAlert(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.alert.FeatureGroupAlert) JobAlert(io.hops.hopsworks.persistence.entity.jobs.description.JobAlert) ArrayList(java.util.ArrayList) ProjectServiceAlert(io.hops.hopsworks.persistence.entity.project.alert.ProjectServiceAlert) Route(io.hops.hopsworks.alerting.config.dto.Route)

Example 5 with FeatureGroupAlert

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;
}
Also used : FeatureGroupAlert(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.alert.FeatureGroupAlert) AlertReceiver(io.hops.hopsworks.persistence.entity.alertmanager.AlertReceiver) Featuregroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup) ArrayList(java.util.ArrayList) Date(java.util.Date) ProjectServiceAlert(io.hops.hopsworks.persistence.entity.project.alert.ProjectServiceAlert) Project(io.hops.hopsworks.persistence.entity.project.Project) Featurestore(io.hops.hopsworks.persistence.entity.featurestore.Featurestore) JobAlert(io.hops.hopsworks.persistence.entity.jobs.description.JobAlert) Jobs(io.hops.hopsworks.persistence.entity.jobs.description.Jobs)

Aggregations

FeatureGroupAlert (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.alert.FeatureGroupAlert)7 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)3 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)3 ProjectServiceAlert (io.hops.hopsworks.persistence.entity.project.alert.ProjectServiceAlert)3 ApiOperation (io.swagger.annotations.ApiOperation)3 ArrayList (java.util.ArrayList)3 Path (javax.ws.rs.Path)3 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)2 JobAlert (io.hops.hopsworks.persistence.entity.jobs.description.JobAlert)2 Date (java.util.Date)2 Produces (javax.ws.rs.Produces)2 AlertManagerAccessControlException (io.hops.hopsworks.alert.exception.AlertManagerAccessControlException)1 AlertManagerUnreachableException (io.hops.hopsworks.alert.exception.AlertManagerUnreachableException)1 Alert (io.hops.hopsworks.alerting.api.alert.dto.Alert)1 PostableAlert (io.hops.hopsworks.alerting.api.alert.dto.PostableAlert)1 Route (io.hops.hopsworks.alerting.config.dto.Route)1 AlertManagerClientCreateException (io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException)1 AlertManagerResponseException (io.hops.hopsworks.alerting.exceptions.AlertManagerResponseException)1 AlertDTO (io.hops.hopsworks.api.alert.AlertDTO)1 AlertException (io.hops.hopsworks.exceptions.AlertException)1