use of io.hops.hopsworks.alerting.config.dto.AlertManagerConfig in project hopsworks by logicalclocks.
the class AlertManagerConfiguration method addRoute.
public void addRoute(Route route) throws AlertManagerDuplicateEntryException, AlertManagerConfigUpdateException, AlertManagerConfigReadException, AlertManagerConfigCtrlCreateException, AlertManagerUnreachableException, AlertManagerClientCreateException, AlertManagerNoSuchElementException {
doSanityCheck();
AlertManagerConfig alertManagerConfig = alertManagerConfigController.addRoute(route);
writeAndReload(alertManagerConfig);
}
use of io.hops.hopsworks.alerting.config.dto.AlertManagerConfig in project hopsworks by logicalclocks.
the class AlertManagerConfiguration method cleanProject.
public void cleanProject(Project project) throws AlertManagerConfigCtrlCreateException, AlertManagerConfigReadException, AlertManagerConfigUpdateException, AlertManagerUnreachableException, AlertManagerClientCreateException {
AlertManagerConfig alertManagerConfig = read();
List<Route> routes = alertManagerConfig.getRoute() == null || alertManagerConfig.getRoute().getRoutes() == null ? Collections.emptyList() : alertManagerConfig.getRoute().getRoutes();
List<Receiver> receivers = alertManagerConfig.getReceivers() == null ? Collections.emptyList() : alertManagerConfig.getReceivers();
List<Receiver> receiversToRemove = new ArrayList<>();
for (Receiver receiver : receivers) {
if (receiver.getName().startsWith(Constants.RECEIVER_NAME_PREFIX.replace(Constants.PROJECT_PLACE_HOLDER, project.getName()))) {
receiversToRemove.add(receiver);
}
}
List<Route> routesToRemove = new ArrayList<>();
for (Route route : routes) {
if (isRouteInProject(route, project) || receiversToRemove.contains(new Receiver(route.getReceiver()))) {
routesToRemove.add(route);
}
}
if (!routesToRemove.isEmpty() || !receiversToRemove.isEmpty()) {
if (!routesToRemove.isEmpty()) {
alertManagerConfig.getRoute().getRoutes().removeAll(routesToRemove);
}
if (!receiversToRemove.isEmpty()) {
alertManagerConfig.getReceivers().removeAll(receiversToRemove);
for (Receiver receiver : receiversToRemove) {
removeReceiverFromDatabase(receiver.getName());
}
}
writeAndReload(alertManagerConfig);
}
}
use of io.hops.hopsworks.alerting.config.dto.AlertManagerConfig in project hopsworks by logicalclocks.
the class AlertManagerConfiguration method updateTemplates.
public void updateTemplates(List<String> templates) throws AlertManagerConfigCtrlCreateException, AlertManagerClientCreateException, AlertManagerUnreachableException, AlertManagerConfigReadException, AlertManagerConfigUpdateException {
doSanityCheck();
AlertManagerConfig alertManagerConfig = alertManagerConfigController.updateTemplates(templates);
writeAndReload(alertManagerConfig);
}
use of io.hops.hopsworks.alerting.config.dto.AlertManagerConfig in project hopsworks by logicalclocks.
the class AlertManagerConfiguration method updateRoute.
public void updateRoute(Route route) throws AlertManagerConfigCtrlCreateException, AlertManagerClientCreateException, AlertManagerUnreachableException, AlertManagerConfigReadException, AlertManagerConfigUpdateException {
doSanityCheck();
AlertManagerConfig alertManagerConfig = alertManagerConfigController.updateGlobalRoute(route);
writeAndReload(alertManagerConfig);
}
use of io.hops.hopsworks.alerting.config.dto.AlertManagerConfig in project hopsworks by logicalclocks.
the class AlertManagerConfiguration method removeReceiver.
public void removeReceiver(String name, boolean cascade) throws AlertManagerConfigUpdateException, AlertManagerConfigCtrlCreateException, AlertManagerUnreachableException, AlertManagerClientCreateException, AlertManagerConfigReadException {
doSanityCheck();
AlertManagerConfig alertManagerConfig = alertManagerConfigController.removeReceiver(name, cascade);
writeAndReload(alertManagerConfig, name, null);
}
Aggregations