Search in sources :

Example 1 with PrometheusAlertResponse

use of com.sequenceiq.periscope.api.model.PrometheusAlertResponse in project cloudbreak by hortonworks.

the class AutoscalingUtil method getAlertId.

static Long getAlertId(AutoscaleClient autoscaleClient, Long clusterId, String alertName) {
    Long alertId = null;
    AlertEndpoint alertEndpoint = autoscaleClient.alertEndpoint();
    List<PrometheusAlertResponse> prometheusAlertResponses = alertEndpoint.getPrometheusAlerts(clusterId);
    for (PrometheusAlertResponse entry : prometheusAlertResponses) {
        if (entry.getAlertName().equals(alertName)) {
            alertId = entry.getId();
        }
    }
    Assert.assertNotNull(alertId);
    return alertId;
}
Also used : AlertEndpoint(com.sequenceiq.periscope.api.endpoint.v1.AlertEndpoint) PrometheusAlertResponse(com.sequenceiq.periscope.api.model.PrometheusAlertResponse)

Example 2 with PrometheusAlertResponse

use of com.sequenceiq.periscope.api.model.PrometheusAlertResponse in project cloudbreak by hortonworks.

the class PrometheusAlertResponseConverter method convert.

@Override
public PrometheusAlertResponse convert(PrometheusAlert source) {
    PrometheusAlertResponse json = new PrometheusAlertResponse();
    json.setId(source.getId());
    json.setScalingPolicyId(source.getScalingPolicyId());
    json.setAlertName(source.getName());
    json.setDescription(source.getDescription());
    json.setPeriod(source.getPeriod());
    json.setAlertRuleName(source.getAlertRule());
    json.setAlertState(source.getAlertState());
    Map<String, Object> parameters = source.getParameters().getMap();
    json.setAlertOperator(AlertOperator.valueOf(String.valueOf(parameters.get(OPERATOR_PARAM_KEY))));
    json.setThreshold(Double.valueOf(String.valueOf(parameters.get(THRESHOLD_PARAM_KEY))));
    if (source.getScalingPolicy() != null) {
        json.setScalingPolicy(scalingPolicyRequestConverter.convert(source.getScalingPolicy()));
    }
    return json;
}
Also used : PrometheusAlertResponse(com.sequenceiq.periscope.api.model.PrometheusAlertResponse)

Example 3 with PrometheusAlertResponse

use of com.sequenceiq.periscope.api.model.PrometheusAlertResponse in project cloudbreak by hortonworks.

the class ClusterConverter method convert.

@Override
public AutoscaleClusterResponse convert(Cluster source) {
    AutoscaleClusterResponse json = new AutoscaleClusterResponse(source.getHost(), source.getPort(), source.getAmbariUser(), source.getStackId(), source.isAutoscalingEnabled(), source.getId(), source.getState().name());
    if (!source.getMetricAlerts().isEmpty()) {
        List<MetricAlertResponse> metricAlerts = metricAlertResponseConverter.convertAllToJson(new ArrayList<>(source.getMetricAlerts()));
        json.setMetricAlerts(metricAlerts);
    }
    if (!source.getTimeAlerts().isEmpty()) {
        List<TimeAlertResponse> timeAlertRequests = timeAlertResponseConverter.convertAllToJson(new ArrayList<>(source.getTimeAlerts()));
        json.setTimeAlerts(timeAlertRequests);
    }
    if (!source.getPrometheusAlerts().isEmpty()) {
        List<PrometheusAlertResponse> prometheusAlertRequests = prometheusAlertResponseConverter.convertAllToJson(new ArrayList<>(source.getPrometheusAlerts()));
        json.setPrometheusAlerts(prometheusAlertRequests);
    }
    ScalingConfigurationRequest scalingConfig = new ScalingConfigurationRequest(source.getMinSize(), source.getMaxSize(), source.getCoolDown());
    json.setScalingConfiguration(scalingConfig);
    return json;
}
Also used : AutoscaleClusterResponse(com.sequenceiq.periscope.api.model.AutoscaleClusterResponse) ScalingConfigurationRequest(com.sequenceiq.periscope.api.model.ScalingConfigurationRequest) TimeAlertResponse(com.sequenceiq.periscope.api.model.TimeAlertResponse) PrometheusAlertResponse(com.sequenceiq.periscope.api.model.PrometheusAlertResponse) MetricAlertResponse(com.sequenceiq.periscope.api.model.MetricAlertResponse)

Aggregations

PrometheusAlertResponse (com.sequenceiq.periscope.api.model.PrometheusAlertResponse)3 AlertEndpoint (com.sequenceiq.periscope.api.endpoint.v1.AlertEndpoint)1 AutoscaleClusterResponse (com.sequenceiq.periscope.api.model.AutoscaleClusterResponse)1 MetricAlertResponse (com.sequenceiq.periscope.api.model.MetricAlertResponse)1 ScalingConfigurationRequest (com.sequenceiq.periscope.api.model.ScalingConfigurationRequest)1 TimeAlertResponse (com.sequenceiq.periscope.api.model.TimeAlertResponse)1