Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Slo Alert in Output #726

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions krkn/prometheus/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from krkn_lib.elastic.krkn_elastic import KrknElastic
from krkn_lib.models.elastic.models import ElasticAlert
from krkn_lib.models.krkn import ChaosRunAlertSummary, ChaosRunAlert
from krkn_lib.models.telemetry import SloAlert
from krkn_lib.prometheus.krkn_prometheus import KrknPrometheus


Expand All @@ -27,8 +28,8 @@ def alerts(
alert_profile,
elastic_collect_alerts,
elastic_alerts_index,
):

) -> list[SloAlert]:
slo_alert_list: list[SloAlert] = []
if alert_profile is None or os.path.exists(alert_profile) is False:
logging.error(f"{alert_profile} alert profile does not exist")
sys.exit(1)
Expand All @@ -52,6 +53,8 @@ def alerts(
datetime.datetime.fromtimestamp(start_time),
datetime.datetime.fromtimestamp(end_time),
)
if (processed_alert[0] and processed_alert[1]):
slo_alert_list.append(SloAlert(processed_alert[1][:23], alert["severity"], processed_alert[1][23:]))
if (
processed_alert[0]
and processed_alert[1]
Expand All @@ -68,7 +71,7 @@ def alerts(
if result == -1:
logging.error("failed to save alert on ElasticSearch")
pass

return slo_alert_list

def critical_alerts(
prom_cli: KrknPrometheus,
Expand Down
3 changes: 2 additions & 1 deletion run_kraken.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def main(cfg) -> int:
if enable_alerts:
logging.info("Alerts checking is enabled")
if alert_profile:
prometheus_plugin.alerts(
slo_alerts_list = prometheus_plugin.alerts(
prometheus,
elastic_search,
run_uuid,
Expand All @@ -469,6 +469,7 @@ def main(cfg) -> int:
elastic_colllect_alerts,
elastic_alerts_index,
)
chaos_telemetry.slo_alert = slo_alerts_list

else:
logging.error("Alert profile is not defined")
Expand Down
Loading