跳到主要内容

PagerDuty 告警

信息

✨ PagerDuty 告警功能包含在 LiteLLM 企业版中

企业版定价

获取免费 7 天试用密钥

处理两种类型的告警

  • LLM API 失败率过高。配置 Y 秒内发生 X 次失败时触发告警。
  • LLM 请求挂起数量过多。配置 Y 秒内发生 X 次挂起时触发告警。

快速入门

  1. 在您的环境变量中设置 PAGERDUTY_API_KEY="d8bxxxxx"
PAGERDUTY_API_KEY="d8bxxxxx"
  1. 在您的配置文件中设置 PagerDuty 告警。
model_list:
- model_name: "openai/*"
litellm_params:
model: "openai/*"
api_key: os.environ/OPENAI_API_KEY

general_settings:
alerting: ["pagerduty"]
alerting_args:
failure_threshold: 1 # Number of requests failing in a window
failure_threshold_window_seconds: 10 # Window in seconds

# Requests hanging threshold
hanging_threshold_seconds: 0.0000001 # Number of seconds of waiting for a response before a request is considered hanging
hanging_threshold_window_seconds: 10 # Window in seconds
  1. 测试

启动 LiteLLM 代理

litellm --config config.yaml

LLM API 失败告警

尝试向代理发送一个错误的请求

curl -i --location 'http://0.0.0.0:4000/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer sk-1234' \
--data ' {
"model": "gpt-4o",
"user": "hi",
"messages": [
{
"role": "user",
"bad_param": "i like coffee"
}
]
}
'

LLM 挂起告警

尝试向代理发送一个挂起的请求

由于我们的挂起阈值为 0.0000001 秒,您应该会看到一个告警。

curl -i --location 'http://0.0.0.0:4000/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer sk-1234' \
--data ' {
"model": "gpt-4o",
"user": "hi",
"messages": [
{
"role": "user",
"content": "i like coffee"
}
]
}
'