Exemplo n.º 1
0
def test_alerting_works():
    """
    If alerting works then there is at least one alert.
    """
    prometheus = ocs_ci.utility.prometheus.PrometheusAPI()
    alerts_response = prometheus.get(
        "alerts", payload={"silenced": False, "inhibited": False}
    )
    assert alerts_response.ok is True
    alerts = alerts_response.json()["data"]["alerts"]
    log.info(f"Prometheus Alerts: {alerts}")
    assert len(alerts) > 0
Exemplo n.º 2
0
def get_metrics_persistentvolumeclaims_info():
    """
    Returns the created pvc information on prometheus pod

    Returns:
        response.content (dict): The pvc metrics collected on prometheus pod

    """
    prometheus = ocs_ci.utility.prometheus.PrometheusAPI()
    response = prometheus.get(
        'query?query=kube_pod_spec_volumes_persistentvolumeclaims_info')
    return json.loads(response.content.decode('utf-8'))
Exemplo n.º 3
0
def test_alerting_works():
    """
    If alerting works then there is at least one alert.
    """
    prometheus = ocs_ci.utility.prometheus.PrometheusAPI()
    alerts_response = prometheus.get('alerts',
                                     payload={
                                         'silenced': False,
                                         'inhibited': False
                                     })
    assert alerts_response.ok is True
    alerts = alerts_response.json()['data']['alerts']
    log.info(f"Prometheus Alerts: {alerts}")
    assert len(alerts) > 0
Exemplo n.º 4
0
def get_metrics_persistentvolumeclaims_info():
    """
    Returns the created pvc information on prometheus pod

    Returns:
        response.content (dict): The pvc metrics collected on prometheus pod

    """

    prometheus = ocs_ci.utility.prometheus.PrometheusAPI()
    response = prometheus.get(
        "query?query=kube_pod_spec_volumes_persistentvolumeclaims_info")
    if response.status_code == 503:
        raise ServiceUnavailable("Failed to handle the request")
    return json.loads(response.content.decode("utf-8"))
Exemplo n.º 5
0
def test_prometheus_rule_failures():
    """
    There should be no PrometheusRuleFailures alert when OCS is configured.
    """
    prometheus = ocs_ci.utility.prometheus.PrometheusAPI()
    alerts_response = prometheus.get("alerts",
                                     payload={
                                         "silenced": False,
                                         "inhibited": False
                                     })
    assert alerts_response.ok is True
    alerts = alerts_response.json()["data"]["alerts"]
    log.info(f"Prometheus Alerts: {alerts}")
    assert constants.ALERT_PROMETHEUSRULEFAILURES not in [
        alert["labels"]["alertname"] for alert in alerts
    ]
Exemplo n.º 6
0
def check_ceph_health_status_metrics_on_prometheus(mgr_pod):
    """
    Check ceph health status metric is collected on prometheus pod

    Args:
        mgr_pod (str): Name of the mgr pod

    Returns:
        bool: True on success, false otherwise

    """
    prometheus = ocs_ci.utility.prometheus.PrometheusAPI()
    response = prometheus.get("query?query=ceph_health_status")
    ceph_health_metric = json.loads(response.content.decode("utf-8"))
    return bool([
        mgr_pod
        for health_status in ceph_health_metric.get("data").get("result")
        if mgr_pod == health_status.get("metric").get("pod")
    ])