Search in sources :

Example 26 with AlertManagerConfig

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);
}
Also used : AlertManagerConfig(io.hops.hopsworks.alerting.config.dto.AlertManagerConfig)

Example 27 with 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);
    }
}
Also used : AlertManagerConfig(io.hops.hopsworks.alerting.config.dto.AlertManagerConfig) ArrayList(java.util.ArrayList) AlertReceiver(io.hops.hopsworks.persistence.entity.alertmanager.AlertReceiver) Receiver(io.hops.hopsworks.alerting.config.dto.Receiver) Route(io.hops.hopsworks.alerting.config.dto.Route)

Example 28 with 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);
}
Also used : AlertManagerConfig(io.hops.hopsworks.alerting.config.dto.AlertManagerConfig)

Example 29 with 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);
}
Also used : AlertManagerConfig(io.hops.hopsworks.alerting.config.dto.AlertManagerConfig)

Example 30 with 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);
}
Also used : AlertManagerConfig(io.hops.hopsworks.alerting.config.dto.AlertManagerConfig)

Aggregations

AlertManagerConfig (io.hops.hopsworks.alerting.config.dto.AlertManagerConfig)53 Receiver (io.hops.hopsworks.alerting.config.dto.Receiver)22 Test (org.junit.Test)19 EmailConfig (io.hops.hopsworks.alerting.config.dto.EmailConfig)8 ArrayList (java.util.ArrayList)8 AlertManagerDuplicateEntryException (io.hops.hopsworks.alerting.exceptions.AlertManagerDuplicateEntryException)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 Route (io.hops.hopsworks.alerting.config.dto.Route)5 SlackConfig (io.hops.hopsworks.alerting.config.dto.SlackConfig)5 PagerdutyConfig (io.hops.hopsworks.alerting.config.dto.PagerdutyConfig)4 AlertManagerConfigUpdateException (io.hops.hopsworks.alerting.exceptions.AlertManagerConfigUpdateException)4 AlertManagerConfigEntity (io.hops.hopsworks.persistence.entity.alertmanager.AlertManagerConfigEntity)4 AlertReceiver (io.hops.hopsworks.persistence.entity.alertmanager.AlertReceiver)4 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)3 AlertManagerUnreachableException (io.hops.hopsworks.alert.exception.AlertManagerUnreachableException)3 AlertManagerClientCreateException (io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException)3 AlertManagerConfigCtrlCreateException (io.hops.hopsworks.alerting.exceptions.AlertManagerConfigCtrlCreateException)3 AlertManagerConfigReadException (io.hops.hopsworks.alerting.exceptions.AlertManagerConfigReadException)3 File (java.io.File)3 Date (java.util.Date)3