use of io.hops.hopsworks.alerting.api.alert.dto.Silence in project hopsworks by logicalclocks.
the class SilenceBuilder method items.
private SilenceDTO items(SilenceDTO dto, UriInfo uriInfo, ResourceRequest resourceRequest, SilenceBeanParam silenceBeanParam, Project project) throws AlertException {
uri(dto, uriInfo);
expand(dto, resourceRequest);
if (dto.isExpand()) {
List<Silence> silenceList;
try {
if (project != null) {
silenceList = alertManager.getSilences(silenceBeanParam.getSilenceFilterBy().getFilter(), project);
} else {
silenceList = alertManager.getSilences(silenceBeanParam.getSilenceFilterBy().getFilter());
}
} catch (AlertManagerClientCreateException | AlertManagerUnreachableException e) {
throw new AlertException(RESTCodes.AlertErrorCode.FAILED_TO_CONNECT, Level.FINE, e.getMessage());
} catch (AlertManagerResponseException e) {
throw new AlertException(RESTCodes.AlertErrorCode.RESPONSE_ERROR, Level.FINE, e.getMessage());
} catch (AlertManagerAccessControlException e) {
throw new AlertException(RESTCodes.AlertErrorCode.ACCESS_CONTROL_EXCEPTION, Level.FINE, e.getMessage());
}
if (!Strings.isNullOrEmpty(silenceBeanParam.getSilenceFilterBy().getStatus())) {
silenceList = silenceList.stream().filter((s) -> s.getStatus().getState().equals(silenceBeanParam.getSilenceFilterBy().getStatus())).collect(Collectors.toList());
}
if (!Strings.isNullOrEmpty(silenceBeanParam.getSilenceFilterBy().getCreatedBy())) {
silenceList = silenceList.stream().filter((s) -> s.getCreatedBy().equals(silenceBeanParam.getSilenceFilterBy().getCreatedBy())).collect(Collectors.toList());
}
dto.setCount((long) silenceList.size());
return items(dto, uriInfo, resourceRequest, silenceList, silenceBeanParam);
}
return dto;
}
use of io.hops.hopsworks.alerting.api.alert.dto.Silence in project hopsworks by logicalclocks.
the class AlertManager method getSilence.
public Silence getSilence(String uuid) throws AlertManagerResponseException, AlertManagerClientCreateException, AlertManagerUnreachableException {
doClientSanityCheck();
try {
Silence response = client.getSilence(uuid);
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.Silence in project hopsworks by logicalclocks.
the class AlertManager method getSilences.
public List<Silence> getSilences(Set<String> filters) throws AlertManagerResponseException, AlertManagerClientCreateException, AlertManagerUnreachableException {
doClientSanityCheck();
try {
List<Silence> response = client.getSilences(filters);
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.Silence in project hopsworks by logicalclocks.
the class AlertManagerClient method getSilences.
public List<Silence> getSilences(Set<String> filters) throws AlertManagerResponseException, AlertManagerServerException {
WebTarget wt = webTarget.path(Settings.ALERTS_API_SILENCES);
wt = setFilters(wt, filters);
LOGGER.log(Level.FINE, "Sending request getSilences to: {0}", wt.toString());
List<Silence> silences = getResponseList(sendRequest(wt.request(MediaType.APPLICATION_JSON), RequestMethod.GET, null), Silence.class);
return silences;
}
use of io.hops.hopsworks.alerting.api.alert.dto.Silence in project hopsworks by logicalclocks.
the class AlertManagerClient method getSilence.
public Silence getSilence(String uuid) throws AlertManagerResponseException, AlertManagerServerException {
WebTarget wt = webTarget.path(Settings.ALERTS_API_SILENCE).path(uuid);
LOGGER.log(Level.FINE, "Sending request getSilence to: {0}", wt.toString());
Silence silence = getResponse(sendRequest(wt.request(MediaType.APPLICATION_JSON), RequestMethod.GET, null), Silence.class);
return silence;
}
Aggregations