Search in sources :

Example 1 with Alert

use of io.hops.hopsworks.alerting.api.alert.dto.Alert in project hopsworks by logicalclocks.

the class ProjectAlertsResource method getTestById.

@POST
@Path("{id}/test")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Test alert by Id.", response = ProjectAlertsDTO.class)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getTestById(@PathParam("id") Integer id, @Context UriInfo uriInfo, @Context SecurityContext sc) throws ProjectException, AlertException {
    Project project = getProject();
    ProjectServiceAlert projectServiceAlert = projectServiceAlertsFacade.findByProjectAndId(project, id);
    List<Alert> alerts;
    try {
        alerts = alertController.testAlert(project, projectServiceAlert);
    } catch (AlertManagerUnreachableException | AlertManagerClientCreateException e) {
        throw new AlertException(RESTCodes.AlertErrorCode.FAILED_TO_CONNECT, Level.FINE, e.getMessage());
    } catch (AlertManagerAccessControlException e) {
        throw new AlertException(RESTCodes.AlertErrorCode.ACCESS_CONTROL_EXCEPTION, Level.FINE, e.getMessage());
    } catch (AlertManagerResponseException e) {
        throw new AlertException(RESTCodes.AlertErrorCode.RESPONSE_ERROR, Level.FINE, e.getMessage());
    }
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.ALERTS);
    AlertDTO alertDTO = alertBuilder.getAlertDTOs(uriInfo, resourceRequest, alerts, project);
    return Response.ok().entity(alertDTO).build();
}
Also used : AlertDTO(io.hops.hopsworks.api.alert.AlertDTO) FeatureGroupAlertDTO(io.hops.hopsworks.api.featurestore.datavalidation.alert.FeatureGroupAlertDTO) Project(io.hops.hopsworks.persistence.entity.project.Project) AlertManagerUnreachableException(io.hops.hopsworks.alert.exception.AlertManagerUnreachableException) AlertManagerAccessControlException(io.hops.hopsworks.alert.exception.AlertManagerAccessControlException) ProjectServiceAlert(io.hops.hopsworks.persistence.entity.project.alert.ProjectServiceAlert) Alert(io.hops.hopsworks.alerting.api.alert.dto.Alert) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) ProjectServiceAlert(io.hops.hopsworks.persistence.entity.project.alert.ProjectServiceAlert) AlertException(io.hops.hopsworks.exceptions.AlertException) AlertManagerResponseException(io.hops.hopsworks.alerting.exceptions.AlertManagerResponseException) AlertManagerClientCreateException(io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 2 with Alert

use of io.hops.hopsworks.alerting.api.alert.dto.Alert in project hopsworks by logicalclocks.

the class AlertManagerClient method getAlerts.

public List<Alert> getAlerts(Boolean active, Boolean silenced, Boolean inhibited, Boolean unprocessed, Set<String> filters, String receiver) throws AlertManagerResponseException, AlertManagerServerException {
    WebTarget wt = webTarget.path(Settings.ALERTS_API_ALERTS);
    wt = setQueryParams(wt, active, silenced, inhibited, unprocessed, filters, receiver);
    LOGGER.log(Level.FINE, "Sending request getAlerts to: {0}", wt.toString());
    List<Alert> alerts = getResponseList(sendRequest(wt.request(MediaType.APPLICATION_JSON), RequestMethod.GET, null), Alert.class);
    return alerts;
}
Also used : Alert(io.hops.hopsworks.alerting.api.alert.dto.Alert) PostableAlert(io.hops.hopsworks.alerting.api.alert.dto.PostableAlert) WebTarget(javax.ws.rs.client.WebTarget)

Example 3 with Alert

use of io.hops.hopsworks.alerting.api.alert.dto.Alert in project hopsworks by logicalclocks.

the class AlertManager method getAlerts.

public List<Alert> getAlerts() throws AlertManagerResponseException, AlertManagerClientCreateException, AlertManagerUnreachableException {
    doClientSanityCheck();
    try {
        List<Alert> response = client.getAlerts();
        registerSuccess();
        return response;
    } catch (AlertManagerServerException e) {
        registerServerError();
        throw new AlertManagerUnreachableException("Alertmanager not reachable." + e.getMessage(), e);
    }
}
Also used : AlertManagerUnreachableException(io.hops.hopsworks.alert.exception.AlertManagerUnreachableException) Alert(io.hops.hopsworks.alerting.api.alert.dto.Alert) PostableAlert(io.hops.hopsworks.alerting.api.alert.dto.PostableAlert) AlertManagerServerException(io.hops.hopsworks.alerting.exceptions.AlertManagerServerException)

Example 4 with Alert

use of io.hops.hopsworks.alerting.api.alert.dto.Alert in project hopsworks by logicalclocks.

the class AlertManager method getAlerts.

public List<Alert> getAlerts(Project project) throws AlertManagerResponseException, AlertManagerClientCreateException, AlertManagerUnreachableException {
    List<Alert> alerts = getAlerts();
    List<Alert> projectAlerts = new ArrayList<>();
    for (Alert alert : alerts) {
        if (alert.getLabels().get(Constants.LABEL_PROJECT) != null && alert.getLabels().get(Constants.LABEL_PROJECT).equals(project.getName())) {
            projectAlerts.add(alert);
        }
    }
    return projectAlerts;
}
Also used : ArrayList(java.util.ArrayList) Alert(io.hops.hopsworks.alerting.api.alert.dto.Alert) PostableAlert(io.hops.hopsworks.alerting.api.alert.dto.PostableAlert)

Example 5 with Alert

use of io.hops.hopsworks.alerting.api.alert.dto.Alert in project hopsworks by logicalclocks.

the class JobAlertsResource method getTestById.

@POST
@Path("{id}/test")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Test alert by Id.", response = ProjectAlertsDTO.class)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getTestById(@PathParam("id") Integer id, @Context UriInfo uriInfo, @Context SecurityContext sc) throws AlertException {
    JobAlert jobAlert = jobalertsFacade.findByJobAndId(job, id);
    List<Alert> alerts;
    try {
        alerts = alertController.testAlert(job.getProject(), jobAlert);
    } catch (AlertManagerUnreachableException | AlertManagerClientCreateException e) {
        throw new AlertException(RESTCodes.AlertErrorCode.FAILED_TO_CONNECT, Level.FINE, e.getMessage());
    } catch (AlertManagerAccessControlException e) {
        throw new AlertException(RESTCodes.AlertErrorCode.ACCESS_CONTROL_EXCEPTION, Level.FINE, e.getMessage());
    } catch (AlertManagerResponseException e) {
        throw new AlertException(RESTCodes.AlertErrorCode.RESPONSE_ERROR, Level.FINE, e.getMessage());
    }
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.ALERTS);
    AlertDTO alertDTO = alertBuilder.getAlertDTOs(uriInfo, resourceRequest, alerts, job.getProject());
    return Response.ok().entity(alertDTO).build();
}
Also used : AlertDTO(io.hops.hopsworks.api.alert.AlertDTO) JobAlert(io.hops.hopsworks.persistence.entity.jobs.description.JobAlert) AlertManagerUnreachableException(io.hops.hopsworks.alert.exception.AlertManagerUnreachableException) AlertManagerAccessControlException(io.hops.hopsworks.alert.exception.AlertManagerAccessControlException) JobAlert(io.hops.hopsworks.persistence.entity.jobs.description.JobAlert) Alert(io.hops.hopsworks.alerting.api.alert.dto.Alert) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) AlertException(io.hops.hopsworks.exceptions.AlertException) AlertManagerResponseException(io.hops.hopsworks.alerting.exceptions.AlertManagerResponseException) AlertManagerClientCreateException(io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Aggregations

Alert (io.hops.hopsworks.alerting.api.alert.dto.Alert)8 AlertManagerUnreachableException (io.hops.hopsworks.alert.exception.AlertManagerUnreachableException)6 PostableAlert (io.hops.hopsworks.alerting.api.alert.dto.PostableAlert)5 AlertManagerAccessControlException (io.hops.hopsworks.alert.exception.AlertManagerAccessControlException)4 AlertManagerClientCreateException (io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException)4 AlertManagerResponseException (io.hops.hopsworks.alerting.exceptions.AlertManagerResponseException)4 AlertException (io.hops.hopsworks.exceptions.AlertException)4 AlertDTO (io.hops.hopsworks.api.alert.AlertDTO)3 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)3 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)3 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)3 ApiOperation (io.swagger.annotations.ApiOperation)3 POST (javax.ws.rs.POST)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 AlertManagerServerException (io.hops.hopsworks.alerting.exceptions.AlertManagerServerException)2 FeatureGroupAlertDTO (io.hops.hopsworks.api.featurestore.datavalidation.alert.FeatureGroupAlertDTO)1 FeatureGroupAlert (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.alert.FeatureGroupAlert)1 JobAlert (io.hops.hopsworks.persistence.entity.jobs.description.JobAlert)1 Project (io.hops.hopsworks.persistence.entity.project.Project)1