use of io.hops.hopsworks.alerting.api.alert.dto.Alert in project hopsworks by logicalclocks.
the class AlertManager method getAlerts.
public List<Alert> getAlerts(Boolean active, Boolean silenced, Boolean inhibited, Boolean unprocessed, Set<String> filters, String receiver) throws AlertManagerResponseException, AlertManagerClientCreateException, AlertManagerUnreachableException {
doClientSanityCheck();
try {
List<Alert> response = client.getAlerts(active, silenced, inhibited, unprocessed, filters, receiver);
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 FeatureGroupAlertResource 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 {
FeatureGroupAlert featureGroupAlert = featureGroupAlertFacade.findByFeatureGroupAndId(featuregroup, id);
List<Alert> alerts;
try {
alerts = alertController.testAlert(featuregroup.getFeaturestore().getProject(), featureGroupAlert);
} 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, featuregroup.getFeaturestore().getProject());
return Response.ok().entity(alertDTO).build();
}
use of io.hops.hopsworks.alerting.api.alert.dto.Alert in project hopsworks by logicalclocks.
the class AlertBuilder method items.
private AlertDTO items(AlertDTO dto, UriInfo uriInfo, ResourceRequest resourceRequest, AlertBeanParam alertBeanParam, Project project) throws AlertException {
uri(dto, uriInfo);
expand(dto, resourceRequest);
if (dto.isExpand()) {
List<Alert> alerts;
try {
if (project != null) {
alerts = alertManager.getAlerts(alertBeanParam.getAlertFilterBy().isActive(), alertBeanParam.getAlertFilterBy().isSilenced(), alertBeanParam.getAlertFilterBy().isInhibited(), alertBeanParam.isUnprocessed(), alertBeanParam.getAlertFilterBy().getFilter(), alertBeanParam.getAlertFilterBy().getReceiver(), project);
} else {
alerts = alertManager.getAlerts(alertBeanParam.getAlertFilterBy().isActive(), alertBeanParam.getAlertFilterBy().isSilenced(), alertBeanParam.getAlertFilterBy().isInhibited(), alertBeanParam.isUnprocessed(), alertBeanParam.getAlertFilterBy().getFilter(), alertBeanParam.getAlertFilterBy().getReceiver());
}
} catch (AlertManagerResponseException a) {
throw new AlertException(RESTCodes.AlertErrorCode.RESPONSE_ERROR, Level.FINE, a.getMessage());
} catch (AlertManagerClientCreateException | AlertManagerUnreachableException 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());
}
dto.setCount((long) alerts.size());
return items(dto, uriInfo, resourceRequest, alertBeanParam, alerts);
}
return dto;
}
Aggregations