diff --git a/ops/alert_on_session_errors/README.md b/ops/alert_on_session_errors/README.md index 898abb3..deb8b73 100644 --- a/ops/alert_on_session_errors/README.md +++ b/ops/alert_on_session_errors/README.md @@ -22,17 +22,19 @@ to look for sessions that ended with an error status in the previous minute. 1. Generate a personal API auth token in the web UI: - 1. Click your user icon in the bottom-left corner of the page - 2. Click the "Client Setup" menu option to go to that page - 3. Click the "Generate Token" button, and copy the generated - [JWT](https://jwt.io/) + - Click your user icon in the bottom-left corner of the page + - Click the "Client Setup" menu option to go to that page + - Click the "Generate Token" button, and copy the generated + [JWT](https://jwt.io/) 2. Import/upload the project 3. Initialize your connections 4. Set/modify these project variables: - - `AUTOKITTEH_API_BASE_URL` (default = `https://api.autokitteh.cloud`) - - `AUTOKITTEH_UI_BASE_URL` (default = `https://app.autokitteh.cloud`) + - `AUTOKITTEH_API_BASE_URL` (default = `https://api.autokitteh.cloud`, + use `http://localhost:9980` for self-hosted servers) + - `AUTOKITTEH_UI_BASE_URL` (default = `https://app.autokitteh.cloud`, + use `http://localhost:9982` for self-hosted servers) - `AUTOKITTEH_AUTH_TOKEN`: the API auth token generated in step 1 above - `SLACK_CHANNEL`: send alert messages to this Slack channel name/ID (default = `autokitteh-alerts`) diff --git a/ops/alert_on_session_errors/program.py b/ops/alert_on_session_errors/program.py index 1007233..12f9f00 100644 --- a/ops/alert_on_session_errors/program.py +++ b/ops/alert_on_session_errors/program.py @@ -13,8 +13,8 @@ from requests import exceptions -API_BASE_URL = os.getenv("AUTOKITTEH_API_BASE_URL", "https://api.autokitteh.cloud") -UI_BASE_URL = os.getenv("AUTOKITTEH_UI_BASE_URL", "https://app.autokitteh.cloud") +API_BASE_URL = os.getenv("AUTOKITTEH_API_BASE_URL", "") +UI_BASE_URL = os.getenv("AUTOKITTEH_UI_BASE_URL", "") JWT = os.getenv("AUTOKITTEH_AUTH_TOKEN", "") SLACK_CHANNEL = os.getenv("SLACK_CHANNEL", "") @@ -44,8 +44,7 @@ def _list_sessions_with_errors(): resp = requests.post(url, headers=headers, json={"stateType": 3}, timeout=10) print(f"API call's Round Trip Time: {resp.elapsed}") - if not resp.ok: - resp.raise_for_status() + resp.raise_for_status() try: return resp.json().get("sessions", [])