(ui) link to slack docs to test soft limit budget alerts

This commit is contained in:
ishaan-jaff 2024-03-02 16:47:00 -08:00
parent ebaf2eef1f
commit 169b085e9c
2 changed files with 13 additions and 7 deletions

View file

@ -71,10 +71,8 @@ const CreateKey: React.FC<CreateKeyProps> = ({
const sendSlackAlert = async () => { const sendSlackAlert = async () => {
try { try {
console.log("Sending Slack alert..."); console.log("Sending Slack alert...");
message.info("Sending Test Slack alert...");
const response = await slackBudgetAlertsHealthCheck(accessToken); const response = await slackBudgetAlertsHealthCheck(accessToken);
console.log("slackBudgetAlertsHealthCheck Response:", response); console.log("slackBudgetAlertsHealthCheck Response:", response);
message.success("Test Slack Alert worked - check your Slack!");
console.log("Testing Slack alert successful"); console.log("Testing Slack alert successful");
} catch (error) { } catch (error) {
console.error("Error sending Slack alert:", error); console.error("Error sending Slack alert:", error);
@ -198,9 +196,14 @@ const CreateKey: React.FC<CreateKeyProps> = ({
<Title className="mt-6">Budgets</Title> <Title className="mt-6">Budgets</Title>
<Text>Soft Limit Budget: ${softBudget}</Text> <Text>Soft Limit Budget: ${softBudget}</Text>
<Button className="mt-3" onClick={sendSlackAlert}> <Button className="mt-3" onClick={sendSlackAlert}>
Test Alert Test Slack Alert
</Button> </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> </div>
) : ( ) : (
<Text>Key being created, this might take 30s</Text> <Text>Key being created, this might take 30s</Text>

View file

@ -818,6 +818,7 @@ export const slackBudgetAlertsHealthCheck = async (accessToken: String) => {
: `health/services?service=slack_budget_alerts`; : `health/services?service=slack_budget_alerts`;
console.log("Checking Slack Budget Alerts service health"); console.log("Checking Slack Budget Alerts service health");
message.info("Sending Test Slack alert...");
const response = await fetch(url, { const response = await fetch(url, {
method: "GET", method: "GET",
@ -829,11 +830,13 @@ export const slackBudgetAlertsHealthCheck = async (accessToken: String) => {
if (!response.ok) { if (!response.ok) {
const errorData = await response.text(); const errorData = await response.text();
console.error("Health Check failed:", errorData); message.error("Failed Slack Alert test: " + errorData);
throw new Error("Health Check failed"); // throw error with message
throw new Error(errorData);
} }
const data = await response.json(); const data = await response.json();
message.success("Test Slack Alert worked - check your Slack!");
console.log("Service Health Response:", data); console.log("Service Health Response:", data);
// You can add additional logic here based on the response if needed // You can add additional logic here based on the response if needed