use of com.sequenceiq.periscope.domain.Ambari in project cloudbreak by hortonworks.
the class ConsulKeyValueService method addAlert.
public PrometheusAlert addAlert(Cluster cluster, PrometheusAlert alert) {
Ambari ambari = cluster.getAmbari();
try {
if (RUNNING.equals(cluster.getState())) {
TlsConfiguration tlsConfig = tlsSecurityService.getConfiguration(cluster);
ConsulClient consulClient = ConsulUtils.createClient(ambari.getHost(), cluster.getPort(), tlsConfig);
String alertKey = getKeyNameForAlert(alert);
consulClient.setKVValue(alertKey, alert.getAlertRule());
LOGGER.info("Alert has been added to Consul KV store with name: '{}' on host: '{}'.", alertKey, ambari.getHost());
}
} catch (Exception e) {
LOGGER.warn("Alert could not be added to Consul KV store:", e);
}
return alert;
}
Aggregations