Merge pull request #3702 from BerriAI/litellm_separate_slack_alerts_channel

[Fix] allow users to opt into specific alert types + Introduce `spend_report` alert type
This commit is contained in:
Ishaan Jaff
2024-05-16 17:05:36 -07:00
committed by GitHub
4 changed files with 58 additions and 4 deletions
+31 -2
View File
@@ -11,7 +11,7 @@ Get alerts for:
- Daily Reports:
- **LLM** Top 5 slowest deployments
- **LLM** Top 5 deployments with most failed requests
- **Spend** Weekly & Monthly spend per Team, Tag
- **Spend** Weekly & Monthly spend per Team, Tag
## Quick Start
@@ -61,8 +61,37 @@ curl -X GET 'http://localhost:4000/health/services?service=slack' \
-H 'Authorization: Bearer sk-1234'
```
## Advanced
### Opting into specific alert types
Set `alert_types` if you want to Opt into only specific alert types
```shell
general_settings:
alerting: ["slack"]
alert_types: ["spend_reports"]
```
All Possible Alert Types
```python
alert_types:
Optional[
List[
Literal[
"llm_exceptions",
"llm_too_slow",
"llm_requests_hanging",
"budget_alerts",
"db_exceptions",
"daily_reports",
"spend_reports",
"cooldown_deployment",
"new_model_added",
]
]
```
## Extras
### Using Discord Webhooks
+12 -2
View File
@@ -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)
+6
View File
@@ -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:
+9
View File
@@ -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,