mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
fix - allow users to opt into specific alert types
This commit is contained in:
parent
f3d340bd3a
commit
a292583ff1
3 changed files with 27 additions and 2 deletions
|
|
@ -87,6 +87,9 @@ class SlackAlerting(CustomLogger):
|
|||
"budget_alerts",
|
||||
"db_exceptions",
|
||||
"daily_reports",
|
||||
"spend_reports",
|
||||
"cooldown_deployment",
|
||||
"new_model_added",
|
||||
]
|
||||
] = [
|
||||
"llm_exceptions",
|
||||
|
|
@ -95,6 +98,9 @@ class SlackAlerting(CustomLogger):
|
|||
"budget_alerts",
|
||||
"db_exceptions",
|
||||
"daily_reports",
|
||||
"spend_reports",
|
||||
"cooldown_deployment",
|
||||
"new_model_added",
|
||||
],
|
||||
alert_to_webhook_url: Optional[
|
||||
Dict
|
||||
|
|
@ -726,6 +732,7 @@ Model Info:
|
|||
"budget_alerts",
|
||||
"db_exceptions",
|
||||
"daily_reports",
|
||||
"spend_reports",
|
||||
"new_model_added",
|
||||
"cooldown_deployment",
|
||||
],
|
||||
|
|
@ -748,6 +755,9 @@ Model Info:
|
|||
if self.alerting is None:
|
||||
return
|
||||
|
||||
if alert_type not in self.alert_types:
|
||||
return
|
||||
|
||||
from datetime import datetime
|
||||
import json
|
||||
|
||||
|
|
@ -942,7 +952,7 @@ Model Info:
|
|||
await self.send_alert(
|
||||
message=_weekly_spend_message,
|
||||
level="Low",
|
||||
alert_type="daily_reports",
|
||||
alert_type="spend_reports",
|
||||
)
|
||||
except Exception as e:
|
||||
verbose_proxy_logger.error("Error sending weekly spend report", e)
|
||||
|
|
@ -993,7 +1003,7 @@ Model Info:
|
|||
await self.send_alert(
|
||||
message=_spend_message,
|
||||
level="Low",
|
||||
alert_type="daily_reports",
|
||||
alert_type="spend_reports",
|
||||
)
|
||||
except Exception as e:
|
||||
verbose_proxy_logger.error("Error sending weekly spend report", e)
|
||||
|
|
|
|||
|
|
@ -10171,8 +10171,14 @@ async def health_services_endpoint(
|
|||
asyncio.create_task(
|
||||
proxy_logging_obj.slack_alerting_instance.send_weekly_spend_report()
|
||||
)
|
||||
|
||||
alert_types = (
|
||||
proxy_logging_obj.slack_alerting_instance.alert_types or []
|
||||
)
|
||||
alert_types = list(alert_types)
|
||||
return {
|
||||
"status": "success",
|
||||
"alert_types": alert_types,
|
||||
"message": "Mock Slack Alert sent, verify Slack Alert Received on your channel",
|
||||
}
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -74,6 +74,9 @@ class ProxyLogging:
|
|||
"budget_alerts",
|
||||
"db_exceptions",
|
||||
"daily_reports",
|
||||
"spend_reports",
|
||||
"cooldown_deployment",
|
||||
"new_model_added",
|
||||
]
|
||||
] = [
|
||||
"llm_exceptions",
|
||||
|
|
@ -82,6 +85,9 @@ class ProxyLogging:
|
|||
"budget_alerts",
|
||||
"db_exceptions",
|
||||
"daily_reports",
|
||||
"spend_reports",
|
||||
"cooldown_deployment",
|
||||
"new_model_added",
|
||||
]
|
||||
self.slack_alerting_instance = SlackAlerting(
|
||||
alerting_threshold=self.alerting_threshold,
|
||||
|
|
@ -104,6 +110,9 @@ class ProxyLogging:
|
|||
"budget_alerts",
|
||||
"db_exceptions",
|
||||
"daily_reports",
|
||||
"spend_reports",
|
||||
"cooldown_deployment",
|
||||
"new_model_added",
|
||||
]
|
||||
]
|
||||
] = None,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue