use of com.thinkbiganalytics.servicemonitor.model.ServiceAlert in project kylo by Teradata.
the class ActivemqServiceStatusCheck method activemqStatus.
/**
* Check if Activemq is running
*
* @return Status of Activemq
*/
private ServiceComponent activemqStatus() {
String componentName = "Activemq";
String serviceName = SERVICE_NAME;
ServiceComponent component = null;
Connection activemqConnection = null;
/**
* Prepare Alert Message
*/
ServiceAlert alert = null;
alert = new DefaultServiceAlert();
alert.setLabel(componentName);
alert.setServiceName(serviceName);
alert.setComponentName(componentName);
String finalServiceMessage = "";
try {
if (this.activemqPoolConnection != null) {
/**
* Create Instance of Connection from Pool
*/
activemqConnection = this.activemqPoolConnection.createConnection();
/**
* On successful connection , return status to Kylo
*/
finalServiceMessage = "Activemq is running.";
alert.setMessage(finalServiceMessage);
alert.setState(ServiceAlert.STATE.OK);
component = new DefaultServiceComponent.Builder(componentName, ServiceComponent.STATE.UP).message(finalServiceMessage).addAlert(alert).build();
}
} catch (Exception jmsConnectionException) {
finalServiceMessage = "Activemq is down.";
alert.setMessage(finalServiceMessage);
alert.setState(ServiceAlert.STATE.CRITICAL);
component = new DefaultServiceComponent.Builder(componentName, ServiceComponent.STATE.DOWN).message(finalServiceMessage).exception(jmsConnectionException).addAlert(alert).build();
} finally {
if (activemqConnection != null)
try {
activemqConnection.close();
} catch (JMSException e) {
log.error("Unable to close activemq connection", e);
}
}
return component;
}
use of com.thinkbiganalytics.servicemonitor.model.ServiceAlert in project kylo by Teradata.
the class AmbariServicesStatusCheck method healthCheck.
/**
* https://github.com/apache/ambari/blob/trunk/ambari-server/docs/api/v1/host-component-resources.md
*
* State Description <br>
* INIT The initial clean state after the component is first created. <br>
* INSTALLING In the process of installing the component. <br>
* INSTALL_FAILED The component install failed. <br>
* INSTALLED The component has been installed successfully but is not currently running. <br>
* STARTING In the process of starting the component. <br>
* STARTED The component has been installed and started. <br>
* STOPPING In the process of stopping the component. <br>
* UNINSTALLING In the process of uninstalling the component. <br>
* UNINSTALLED The component has been successfully uninstalled. <br>
* WIPING_OUT In the process of wiping out the installed component. <br>
* UPGRADING In the process of upgrading the component. <br>
* MAINTENANCE The component has been marked for maintenance. <br>
* UNKNOWN The component state can not be determined. <br>
*/
@Override
public List<ServiceStatusResponse> healthCheck() {
List<ServiceStatusResponse> serviceStatusResponseList = new ArrayList<>();
// Get the Map of Services and optional Components we are tracking
Map<String, List<String>> definedServiceComponentMap = ServiceMonitorCheckUtil.getMapOfServiceAndComponents(services);
if (definedServiceComponentMap != null && !definedServiceComponentMap.isEmpty()) {
try {
AmbariClient client = ambariClient;
// get the Clusers from ambari
List<String> clusterNames = client.getAmbariClusterNames();
// get the Service Status from Ambari
ServiceComponentInfoSummary response = client.getServiceComponentInfo(clusterNames, services);
// get alert info for these services as well
AlertSummary alertSummary = client.getAlerts(clusterNames, services);
// Convert the Ambari Alerts to the Pipeline Controller Alert
List<ServiceAlert> serviceAlerts = transformAmbariAlert(alertSummary);
// Convert the Ambari ServiceComponentInfo objects to Pipeline Controller ServiceComponents
serviceStatusResponseList = transformAmbariServiceComponents(response, serviceAlerts, definedServiceComponentMap);
} catch (RestClientException e) {
Throwable cause;
if (e.getCause() != null) {
cause = e.getCause();
} else {
cause = e;
}
ServiceComponent ambariServiceComponent = new DefaultServiceComponent.Builder("Unknown", "Ambari", "Ambari REST_CLIENT", ServiceComponent.STATE.DOWN).exception(cause).build();
List<ServiceComponent> ambariComponents = new ArrayList<>();
ambariComponents.add(ambariServiceComponent);
ServiceStatusResponse serviceStatusResponse = new DefaultServiceStatusResponse(ambariServiceComponent.getServiceName(), ambariComponents);
serviceStatusResponseList.add(serviceStatusResponse);
// add the other services as being Warnings
addAmbariServiceErrors(cause.getMessage(), serviceStatusResponseList, definedServiceComponentMap);
}
}
return serviceStatusResponseList;
}
use of com.thinkbiganalytics.servicemonitor.model.ServiceAlert 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;
}
use of com.thinkbiganalytics.servicemonitor.model.ServiceAlert in project kylo by Teradata.
the class ClouderaServicesStatusCheck method apiHealthCheckToServiceAlert.
private ServiceAlert apiHealthCheckToServiceAlert(String componentName, ApiHealthCheck healthCheck) {
ServiceAlert alert = new DefaultServiceAlert();
alert.setComponentName(componentName);
alert.setLabel(healthCheck.getName());
alert.setMessage(healthCheck.getSummary().name());
alert.setState(apiHealthSummaryAlertState(healthCheck.getSummary()));
return alert;
}
use of com.thinkbiganalytics.servicemonitor.model.ServiceAlert in project kylo by Teradata.
the class ClouderaServicesStatusCheck method healthCheck.
@Override
public List<ServiceStatusResponse> healthCheck() {
List<ServiceStatusResponse> serviceStatusResponseList = new ArrayList<>();
// Get the Map of Services and optional Components we are tracking
Map<String, List<String>> definedServiceComponentMap = ServiceMonitorCheckUtil.getMapOfServiceAndComponents(services);
if (definedServiceComponentMap != null && !definedServiceComponentMap.isEmpty()) {
ClouderaRootResource rootResource;
try {
rootResource = clouderaClient.getClouderaResource();
if (rootResource == null) {
throw new Exception("The Cloudera Resource is null... It may still be trying to initialize the Rest Client.");
}
ApiClusterList clusters = rootResource.getPopulatedClusterList();
for (ApiCluster cluster : clusters.getClusters()) {
String clusterName = cluster.getName();
List<ApiService> services = cluster.getServices();
for (ApiService service : services) {
List<ServiceComponent> serviceComponents = new ArrayList<>();
List<ServiceAlert> alerts = new ArrayList<>();
String serviceName = service.getType();
if (definedServiceComponentMap.containsKey(serviceName)) {
service.getHealthSummary();
List<ApiHealthCheck> healthChecks = service.getHealthChecks();
for (ApiHealthCheck healthCheck : healthChecks) {
alerts.add(apiHealthCheckToServiceAlert(null, healthCheck));
}
List<ApiRole> roles = service.getRoles();
for (ApiRole role : roles) {
String roleName = role.getType();
role.getHealthSummary();
List<ApiHealthCheck> roleHealthChecks = role.getHealthChecks();
ServiceComponent.STATE roleState = apiRoleStateToServiceComponentState(role.getRoleState());
List<ServiceAlert> componentAlerts = new ArrayList<>();
for (ApiHealthCheck healthCheck : roleHealthChecks) {
ServiceAlert alert = apiHealthCheckToServiceAlert(roleName, healthCheck);
alerts.add(alert);
componentAlerts.add(alert);
}
ServiceComponent component = new DefaultServiceComponent.Builder(roleName, roleState).clusterName(clusterName).message(role.getRoleState().name()).alerts(componentAlerts).build();
if (definedServiceComponentMap.containsKey(serviceName) && (definedServiceComponentMap.get(serviceName).contains(ServiceMonitorCheckUtil.ALL_COMPONENTS) || definedServiceComponentMap.get(serviceName).contains(component.getName()))) {
serviceComponents.add(component);
}
}
ServiceStatusResponse serviceStatusResponse = new DefaultServiceStatusResponse(serviceName, serviceComponents, alerts);
serviceStatusResponseList.add(serviceStatusResponse);
}
}
}
} catch (Exception e) {
Throwable cause;
if (e.getCause() != null) {
cause = e.getCause();
} else {
cause = e;
}
ServiceComponent clouderaServiceComponent = new DefaultServiceComponent.Builder("Cloudera REST_CLIENT", ServiceComponent.STATE.DOWN).serviceName("Cloudera").clusterName("UNKNOWN").exception(cause).build();
List<ServiceComponent> clouderaComponents = new ArrayList<>();
clouderaComponents.add(clouderaServiceComponent);
ServiceStatusResponse serviceStatusResponse = new DefaultServiceStatusResponse(clouderaServiceComponent.getServiceName(), clouderaComponents);
serviceStatusResponseList.add(serviceStatusResponse);
// add the other services as being Warnings
addClouderaServiceErrors(cause.getMessage(), serviceStatusResponseList, definedServiceComponentMap);
}
}
return serviceStatusResponseList;
}
Aggregations