Skip to content

Commit

Permalink
Prometheus updates
Browse files Browse the repository at this point in the history
  • Loading branch information
paigerube14 committed Feb 13, 2025
1 parent 20f506e commit f112ea3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
15 changes: 8 additions & 7 deletions krkn/prometheus/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ def alerts(
):

if alert_profile is None or os.path.exists(alert_profile) is False:
logging.info(f"{alert_profile} alert profile does not exist")
logging.error(f"{alert_profile} alert profile does not exist")
sys.exit(1)

with open(alert_profile) as profile:
profile_yaml = yaml.safe_load(profile)
if not isinstance(profile_yaml, list):
logging.info(
logging.error(
f"{alert_profile} wrong file format, alert profile must be "
f"a valid yaml file containing a list of items with at least 3 properties: "
f"expr, description, severity"
Expand All @@ -44,7 +44,8 @@ def alerts(

for alert in profile_yaml:
if list(alert.keys()).sort() != ["expr", "description", "severity"].sort():
logging.info(f"wrong alert {alert}, skipping")
logging.error(f"wrong alert {alert}, skipping")
continue

processed_alert = prom_cli.process_alert(
alert,
Expand All @@ -64,7 +65,7 @@ def alerts(
)
result = elastic.push_alert(elastic_alert, elastic_alerts_index)
if result == -1:
logging.info("failed to save alert on ElasticSearch")
logging.error("failed to save alert on ElasticSearch")
pass


Expand Down Expand Up @@ -158,12 +159,12 @@ def metrics(
) -> list[dict[str, list[(int, float)] | str]]:
metrics_list: list[dict[str, list[(int, float)] | str]] = []
if metrics_profile is None or os.path.exists(metrics_profile) is False:
logging.info(f"{metrics_profile} alert profile does not exist")
logging.error(f"{metrics_profile} alert profile does not exist")
sys.exit(1)
with open(metrics_profile) as profile:
profile_yaml = yaml.safe_load(profile)
if not profile_yaml["metrics"] or not isinstance(profile_yaml["metrics"], list):
logging.info(
logging.error(
f"{metrics_profile} wrong file format, alert profile must be "
f"a valid yaml file containing a list of items with 3 properties: "
f"expr, description, severity"
Expand Down Expand Up @@ -222,6 +223,6 @@ def metrics(
run_uuid=run_uuid, index=elastic_metrics_index, raw_data=metrics_list
)
if result == -1:
logging.info("failed to save metrics on ElasticSearch")
logging.error("failed to save metrics on ElasticSearch")

return metrics_list
1 change: 0 additions & 1 deletion run_kraken.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ def main(cfg) -> int:
if not prometheus_url:
try:
connection_data = ocpcli.get_prometheus_api_connection_data()
logging.info('connection data' + str(connection_data.endpoint))
if connection_data:
prometheus_url = connection_data.endpoint
prometheus_bearer_token = connection_data.token
Expand Down

0 comments on commit f112ea3

Please sign in to comment.