Search in sources :

Example 1 with AlertEndpoint

use of com.sequenceiq.periscope.api.endpoint.v1.AlertEndpoint in project cloudbreak by hortonworks.

the class AutoscalingUtil method deletePrometheusAlert.

static void deletePrometheusAlert(AutoscaleClient autoscaleClient, Long clusterId, Long alertId) {
    AlertEndpoint alertEndpoint = autoscaleClient.alertEndpoint();
    alertEndpoint.deletePrometheusAlarm(clusterId, alertId);
}
Also used : AlertEndpoint(com.sequenceiq.periscope.api.endpoint.v1.AlertEndpoint)

Example 2 with AlertEndpoint

use of com.sequenceiq.periscope.api.endpoint.v1.AlertEndpoint 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 3 with AlertEndpoint

use of com.sequenceiq.periscope.api.endpoint.v1.AlertEndpoint in project cloudbreak by hortonworks.

the class AutoscalingUtil method createPrometheusAlert.

static void createPrometheusAlert(AutoscaleClient autoscaleClient, Long clusterId, String alertName, String alertOperator, String alertRuleName, int period, Double threshold) {
    PrometheusAlertRequest prometheusAlertRequest = new PrometheusAlertRequest();
    prometheusAlertRequest.setAlertName(alertName);
    if ("more".equals(alertOperator)) {
        prometheusAlertRequest.setAlertOperator(AlertOperator.MORE_THAN);
    } else {
        prometheusAlertRequest.setAlertOperator(AlertOperator.LESS_THAN);
    }
    prometheusAlertRequest.setAlertRuleName(alertRuleName);
    prometheusAlertRequest.setAlertState(AlertState.OK);
    prometheusAlertRequest.setPeriod(period);
    prometheusAlertRequest.setThreshold(threshold);
    AlertEndpoint alertEndpoint = autoscaleClient.alertEndpoint();
    alertEndpoint.createPrometheusAlert(clusterId, prometheusAlertRequest);
}
Also used : PrometheusAlertRequest(com.sequenceiq.periscope.api.model.PrometheusAlertRequest) AlertEndpoint(com.sequenceiq.periscope.api.endpoint.v1.AlertEndpoint)

Aggregations

AlertEndpoint (com.sequenceiq.periscope.api.endpoint.v1.AlertEndpoint)3 PrometheusAlertRequest (com.sequenceiq.periscope.api.model.PrometheusAlertRequest)1 PrometheusAlertResponse (com.sequenceiq.periscope.api.model.PrometheusAlertResponse)1