Search in sources :

Example 1 with Alert

use of com.thinkbiganalytics.servicemonitor.rest.model.ambari.Alert in project kylo by Teradata.

the class AmbariServicesStatusCheck method transformAmbariAlert.

/**
 * Transform the ambari alerts to Kylo service alerts
 */
private List<ServiceAlert> transformAmbariAlert(AlertSummary alertSummary) {
    List<ServiceAlert> serviceAlerts = new ArrayList<>();
    if (alertSummary != null) {
        List<AlertItem> alertItems = alertSummary.getItems();
        if (alertItems != null) {
            for (AlertItem alertItem : alertItems) {
                Alert alert = alertItem.getAlert();
                ServiceAlert serviceAlert = new DefaultServiceAlert();
                serviceAlert.setServiceName(alertItem.getAlert().getServiceName());
                serviceAlert.setComponentName(alert.getComponentName());
                serviceAlert.setFirstTimestamp(new Date(alert.getOriginalTimestamp()));
                serviceAlert.setLatestTimestamp(new Date(alert.getLatestTimestamp()));
                serviceAlert.setLabel(alert.getLabel());
                serviceAlert.setMessage(alert.getText());
                if (StringUtils.isNotBlank(alert.getState())) {
                    try {
                        serviceAlert.setState(ServiceAlert.STATE.valueOf(alert.getState()));
                    } catch (IllegalArgumentException e) {
                        serviceAlert.setState(ServiceAlert.STATE.UNKNOWN);
                    }
                } else {
                    serviceAlert.setState(ServiceAlert.STATE.UNKNOWN);
                }
                serviceAlerts.add(serviceAlert);
            }
        }
    }
    return serviceAlerts;
}
Also used : ServiceAlert(com.thinkbiganalytics.servicemonitor.model.ServiceAlert) DefaultServiceAlert(com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert) ArrayList(java.util.ArrayList) ServiceAlert(com.thinkbiganalytics.servicemonitor.model.ServiceAlert) Alert(com.thinkbiganalytics.servicemonitor.rest.model.ambari.Alert) DefaultServiceAlert(com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert) DefaultServiceAlert(com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert) AlertItem(com.thinkbiganalytics.servicemonitor.rest.model.ambari.AlertItem) Date(java.util.Date)

Aggregations

DefaultServiceAlert (com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert)1 ServiceAlert (com.thinkbiganalytics.servicemonitor.model.ServiceAlert)1 Alert (com.thinkbiganalytics.servicemonitor.rest.model.ambari.Alert)1 AlertItem (com.thinkbiganalytics.servicemonitor.rest.model.ambari.AlertItem)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1