use of com.sequenceiq.periscope.domain.PrometheusAlert in project cloudbreak by hortonworks.
the class ClusterRequestConverter method convert.
@Override
public Cluster convert(AutoscaleClusterRequest source) {
Cluster cluster = new Cluster();
cluster.setStackId(source.getStackId());
cluster.setAutoscalingEnabled(source.enableAutoscaling());
List<MetricAlertRequest> metricAlertResponses = source.getMetricAlerts();
if (metricAlertResponses != null && !metricAlertResponses.isEmpty()) {
Set<MetricAlert> alerts = metricAlertResponses.stream().map(metricAlertJson -> {
MetricAlert alert = metricAlertRequestConverter.convert(metricAlertJson);
alert.setCluster(cluster);
return alert;
}).collect(Collectors.toSet());
cluster.setMetricAlerts(alerts);
}
List<TimeAlertRequest> timeAlertRequests = source.getTimeAlerts();
if (timeAlertRequests != null && !timeAlertRequests.isEmpty()) {
Set<TimeAlert> alerts = timeAlertRequests.stream().map(timeAlertJson -> {
TimeAlert alert = timeAlertRequestConverter.convert(timeAlertJson);
alert.setCluster(cluster);
return alert;
}).collect(Collectors.toSet());
cluster.setTimeAlerts(alerts);
}
List<PrometheusAlertRequest> prometheusAlertRequests = source.getPrometheusAlerts();
if (prometheusAlertRequests != null && !prometheusAlertRequests.isEmpty()) {
Set<PrometheusAlert> alerts = prometheusAlertRequests.stream().map(prometheusAlertJson -> {
PrometheusAlert alert = prometheusAlertRequestConverter.convert(prometheusAlertJson);
alert.setCluster(cluster);
return alert;
}).collect(Collectors.toSet());
cluster.setPrometheusAlerts(alerts);
}
ScalingConfigurationRequest scalingConfiguration = source.getScalingConfiguration();
if (scalingConfiguration != null) {
cluster.setMinSize(scalingConfiguration.getMinSize());
cluster.setMaxSize(scalingConfiguration.getMaxSize());
cluster.setCoolDown(scalingConfiguration.getCoolDown());
}
return cluster;
}
use of com.sequenceiq.periscope.domain.PrometheusAlert in project cloudbreak by hortonworks.
the class AlertService method deletePrometheusAlert.
public void deletePrometheusAlert(Long clusterId, Long alertId) {
PrometheusAlert alert = prometheusAlertRepository.findByCluster(alertId, clusterId);
Cluster cluster = clusterRepository.findById(clusterId);
consulKeyValueService.deleteAlert(cluster, alert);
Set<PrometheusAlert> alerts = cluster.getPrometheusAlerts().stream().filter(a -> a.getId() != alertId).collect(Collectors.toSet());
cluster.setPrometheusAlerts(alerts);
prometheusAlertRepository.delete(alertId);
clusterRepository.save(cluster);
LOGGER.info("Prometheus alert '{}' has been deleted for cluster 'ID:{}'", alert.getName(), cluster.getId());
}
Aggregations