Search in sources :

Example 1 with AlertGroup

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

the class AlertBuilder method items.

private AlertGroupDTO items(AlertGroupDTO dto, UriInfo uriInfo, ResourceRequest resourceRequest, AlertFilterBy alertFilterBy, Project project) throws AlertException {
    uri(dto, uriInfo);
    expandAlertGroups(dto, resourceRequest);
    if (dto.isExpand()) {
        List<AlertGroup> alertGroups;
        try {
            if (project != null) {
                alertGroups = alertManager.getAlertGroups(alertFilterBy.isActive(), alertFilterBy.isSilenced(), alertFilterBy.isInhibited(), alertFilterBy.getFilter(), alertFilterBy.getReceiver(), project);
            } else {
                alertGroups = alertManager.getAlertGroups(alertFilterBy.isActive(), alertFilterBy.isSilenced(), alertFilterBy.isInhibited(), alertFilterBy.getFilter(), alertFilterBy.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) alertGroups.size());
        return items(dto, uriInfo, resourceRequest, alertGroups);
    }
    return dto;
}
Also used : AlertGroup(io.hops.hopsworks.alerting.api.alert.dto.AlertGroup) AlertManagerUnreachableException(io.hops.hopsworks.alert.exception.AlertManagerUnreachableException) AlertManagerAccessControlException(io.hops.hopsworks.alert.exception.AlertManagerAccessControlException) AlertManagerResponseException(io.hops.hopsworks.alerting.exceptions.AlertManagerResponseException) AlertException(io.hops.hopsworks.exceptions.AlertException) AlertManagerClientCreateException(io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException)

Example 2 with AlertGroup

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

the class AlertManager method getAlertGroups.

public List<AlertGroup> getAlertGroups(Boolean active, Boolean silenced, Boolean inhibited, Set<String> filters, String receiver) throws AlertManagerResponseException, AlertManagerClientCreateException, AlertManagerUnreachableException {
    doClientSanityCheck();
    try {
        List<AlertGroup> response = client.getAlertGroups(active, silenced, inhibited, filters, receiver);
        registerSuccess();
        return response;
    } catch (AlertManagerServerException e) {
        registerServerError();
        throw new AlertManagerUnreachableException("Alertmanager not reachable." + e.getMessage(), e);
    }
}
Also used : AlertGroup(io.hops.hopsworks.alerting.api.alert.dto.AlertGroup) AlertManagerUnreachableException(io.hops.hopsworks.alert.exception.AlertManagerUnreachableException) AlertManagerServerException(io.hops.hopsworks.alerting.exceptions.AlertManagerServerException)

Aggregations

AlertManagerUnreachableException (io.hops.hopsworks.alert.exception.AlertManagerUnreachableException)2 AlertGroup (io.hops.hopsworks.alerting.api.alert.dto.AlertGroup)2 AlertManagerAccessControlException (io.hops.hopsworks.alert.exception.AlertManagerAccessControlException)1 AlertManagerClientCreateException (io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException)1 AlertManagerResponseException (io.hops.hopsworks.alerting.exceptions.AlertManagerResponseException)1 AlertManagerServerException (io.hops.hopsworks.alerting.exceptions.AlertManagerServerException)1 AlertException (io.hops.hopsworks.exceptions.AlertException)1