Alert Configuration

Configure budget alerts to notify you when spending reaches certain thresholds. Set up multiple alert levels for progressive warnings.

Alert Level Threshold Action Status
Warning 50% ($150) Email notification ✓ Active
Caution 75% ($225) Email + Slack ✓ Active
Critical 90% ($270) Email + SMS + Slack ✓ Active
Exceeded 100% ($300) Block requests ✓ Active

Implementation

budget_alerts.py
# Budget Alert System from datetime import datetime import smtplib class BudgetAlertManager: def __init__(self, budget_limit): self.budget_limit = budget_limit self.thresholds = [0.5, 0.75, 0.9, 1.0] self.notified = set() def check_budget(self, current_spend): percentage = current_spend / self.budget_limit for threshold in self.thresholds: if percentage >= threshold and threshold not in self.notified: self.notified.add(threshold) self.send_alert(threshold, current_spend) def send_alert(self, threshold, spend): level = { 0.5: "WARNING", 0.75: "CAUTION", 0.9: "CRITICAL", 1.0: "EXCEEDED" }[threshold] message = f"Budget Alert: {level} - ${spend:.2f} ({int(threshold*100)}%)" # Send notification print(message)

◈ Related Topics