watchtowerai-log-analyzer / notify_slack.py
Tuathe's picture
Update notify_slack.py
e6c37e4 verified
raw
history blame contribute delete
607 Bytes
import requests
import streamlit as st
SLACK_WEBHOOK_URL = st.secrets["SLACK_WEBHOOK_URL"]
def send_slack_alert(log_message, s3_link=None):
text = f" *Critical Log Alert*\n```{log_message}```"
if s3_link:
text += f"\n [Runbook]({s3_link})"
payload = {"text": text}
try:
response = requests.post(SLACK_WEBHOOK_URL, json=payload)
if response.status_code == 200:
print(" Slack alert sent.")
else:
print(f" Slack alert failed: {response.status_code} {response.text}")
except Exception as e:
print(" Slack error:", str(e))