Auto-generated documentation for ocs_ci.utility.prometheus module.
class PrometheusAPI(object):
def __init__(user=None, password=None):
This is wrapper class for Prometheus API.
def check_alert_cleared(label, measure_end_time, time_min=30):
Check that all alerts with provided label are cleared.
label
str - Alerts labelmeasure_end_time
int - Timestamp of measurement endtime_min
int - Number of seconds to wait for alert to be cleared since measurement end
def generate_cert():
Generate CA certificate from kubeconfig for API.
TODO: find proper way how to generate/load cert files.
def get(resource, payload=None):
Get alerts from Prometheus API.
resource
str - Represents part of uri that specifies given resourcepayload
dict - Provide parameters to GET API call. e.g. foralerts
resource this can be{'silenced'
- False, 'inhibited': False}
dict
- Response from Prometheus alerts api
def refresh_connection():
Login into OCP, refresh endpoint and token.
def wait_for_alert(name, state=None, timeout=1200, sleep=5):
Search for alerts that have requested name and state.
name
str - Alert namestate
str - Alert state, if provided then there are searched alerts with provided state. If not provided then alerts are searched for absence of the alert. Loop that looks for alerts is broken when there are no alerts returned from API. This is done because API is not returning any alerts that are not in pending or firing statetimeout
int - Number of seconds for how long the alert should be searchedsleep
int - Number of seconds to sleep in between alert search
list
- List of alert records
def check_alert_list(
label,
msg,
alerts,
states,
severity='warning',
ignore_more_occurences=False,
):
Check list of alerts that there are alerts with requested label and message for each provided state. If some alert is missing then this check fails.
label
str - Alert labelmsg
str - Alert messagealerts
list - List of alerts to checkstates
list - List of states to check, order is importantignore_more_occurences
bool - If true then there is checkced only occurence of alert with requested label, message and state but it is not checked if there is more of occurences than one.