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();
}
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;
}
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);
}
}
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;
}
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();
}
Aggregations