forked from phoenix/litellm-mirror
(ui) link to slack docs to test soft limit budget alerts
This commit is contained in:
parent
ebaf2eef1f
commit
169b085e9c
2 changed files with 13 additions and 7 deletions
|
@ -71,10 +71,8 @@ const CreateKey: React.FC<CreateKeyProps> = ({
|
|||
const sendSlackAlert = async () => {
|
||||
try {
|
||||
console.log("Sending Slack alert...");
|
||||
message.info("Sending Test Slack alert...");
|
||||
const response = await slackBudgetAlertsHealthCheck(accessToken);
|
||||
console.log("slackBudgetAlertsHealthCheck Response:", response);
|
||||
message.success("Test Slack Alert worked - check your Slack!");
|
||||
console.log("Testing Slack alert successful");
|
||||
} catch (error) {
|
||||
console.error("Error sending Slack alert:", error);
|
||||
|
@ -198,9 +196,14 @@ const CreateKey: React.FC<CreateKeyProps> = ({
|
|||
<Title className="mt-6">Budgets</Title>
|
||||
<Text>Soft Limit Budget: ${softBudget}</Text>
|
||||
<Button className="mt-3" onClick={sendSlackAlert}>
|
||||
Test Alert
|
||||
Test Slack Alert
|
||||
</Button>
|
||||
|
||||
<Text className="mt-2">
|
||||
(LiteLLM Docs -
|
||||
<a href="https://docs.litellm.ai/docs/proxy/alerting" target="_blank" className="text-blue-500">
|
||||
Set Up Slack Alerting)
|
||||
</a>
|
||||
</Text>
|
||||
</div>
|
||||
) : (
|
||||
<Text>Key being created, this might take 30s</Text>
|
||||
|
|
|
@ -818,6 +818,7 @@ export const slackBudgetAlertsHealthCheck = async (accessToken: String) => {
|
|||
: `health/services?service=slack_budget_alerts`;
|
||||
|
||||
console.log("Checking Slack Budget Alerts service health");
|
||||
message.info("Sending Test Slack alert...");
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: "GET",
|
||||
|
@ -829,11 +830,13 @@ export const slackBudgetAlertsHealthCheck = async (accessToken: String) => {
|
|||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.text();
|
||||
console.error("Health Check failed:", errorData);
|
||||
throw new Error("Health Check failed");
|
||||
message.error("Failed Slack Alert test: " + errorData);
|
||||
// throw error with message
|
||||
throw new Error(errorData);
|
||||
}
|
||||
|
||||
|
||||
const data = await response.json();
|
||||
message.success("Test Slack Alert worked - check your Slack!");
|
||||
console.log("Service Health Response:", data);
|
||||
|
||||
// You can add additional logic here based on the response if needed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue