Claude API 实时监控与告警
简介
零成本监控Claude API状态与延迟,通过Telegram实时推送故障告警与恢复通知。
原始描述
Monitor the Claude API for outages and latency spikes with rich Telegram alerts. Status monitoring, latency probes, and automatic recovery notifications.
通过你的 Agent 添加
安装目录:skill-36896/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
Claude Watchdog 是一款面向 Claude API 用户的监控工具,通过本地部署的 Python 脚本实现双重监控机制:
-
状态监控 (
status-check.py):每15分钟轮询 Anthropic 官方状态页 (status.claude.com),抓取服务中断事件、组件状态及最新更新,支持按模型过滤(如仅关注 Sonnet 相关故障),零 Token 消耗。 -
延迟探测 (
latency-probe.py):每15分钟通过本地 OpenClaw 网关发送真实 API 请求,测量端到端延迟,基于滚动中位数基线(默认20个样本)智能分级告警(🟡轻微软化/🟠显著延迟/🔴严重故障),单次探测成本约 $0.000001。
安装采用交互式脚本自动化完成:配置环境变量、写入 cron 定时任务、执行初始检测。配置集中存储于 ~/.openclaw/skills/claude-watchdog/,支持热更新。
显著优点
- 成本极低:状态检查完全免费,延迟探测单次成本可忽略
- 告警精准:智能过滤无关模型故障,延迟分级基于动态基线而非固定阈值
- 恢复闭环:自动发送恢复通知,避免人工确认
- 零依赖:纯 Python 标准库,无需 pip 安装
- 本地优先:网关探测反映真实网络路径,比官方状态页更贴近用户体验
潜在局限
- 依赖 OpenClaw 生态:延迟探测需本地 OpenClaw 网关运行,增加架构复杂度
- Telegram 单一渠道:未内置邮件、Slack、PagerDuty 等企业级告警通道
- 无历史分析:仅保留滚动窗口数据,缺乏长期趋势图表与容量规划支持
- 单点故障风险:网关宕机将导致延迟探测失效,需额外监控网关本身
- 权限敏感:配置文件含 Telegram Bot Token 和网关认证密钥,需手动确保 600 权限
适合人群
- 重度依赖 Claude API 的开发者/团队,需第一时间感知服务降级
- 已有 OpenClaw 部署环境,希望扩展可观测性栈的用户
- 成本敏感型用户,拒绝 SaaS 监控服务的订阅费用
- Telegram 重度用户,偏好即时通讯推送
常规风险
风险类型
说明
缓解建议
凭证泄露
.env 文件含敏感 Token,权限配置不当可能导致未授权访问
严格遵循 chmod 600,避免版本控制提交
误报疲劳
网络抖动或网关负载波动可能触发短暂告警
调整 ALERT_MULTIPLIER 和 RECOVER_MULTIPLIER 阈值
探测盲区
网关故障时延迟探测失效,可能遗漏真实 API 问题
叠加官方状态监控作为交叉验证
数据持久化
状态文件长期运行可能累积,需关注磁盘空间
定期清理或轮转日志文件
- 依赖 OpenClaw 生态:延迟探测需本地 OpenClaw 网关运行,增加架构复杂度
- Telegram 单一渠道:未内置邮件、Slack、PagerDuty 等企业级告警通道
- 无历史分析:仅保留滚动窗口数据,缺乏长期趋势图表与容量规划支持
- 单点故障风险:网关宕机将导致延迟探测失效,需额外监控网关本身
- 权限敏感:配置文件含 Telegram Bot Token 和网关认证密钥,需手动确保 600 权限
适合人群
- 重度依赖 Claude API 的开发者/团队,需第一时间感知服务降级
- 已有 OpenClaw 部署环境,希望扩展可观测性栈的用户
- 成本敏感型用户,拒绝 SaaS 监控服务的订阅费用
- Telegram 重度用户,偏好即时通讯推送
常规风险
风险类型
说明
缓解建议
凭证泄露
.env 文件含敏感 Token,权限配置不当可能导致未授权访问
严格遵循 chmod 600,避免版本控制提交
误报疲劳
网络抖动或网关负载波动可能触发短暂告警
调整 ALERT_MULTIPLIER 和 RECOVER_MULTIPLIER 阈值
探测盲区
网关故障时延迟探测失效,可能遗漏真实 API 问题
叠加官方状态监控作为交叉验证
数据持久化
状态文件长期运行可能累积,需关注磁盘空间
定期清理或轮转日志文件
| 风险类型 | 说明 | 缓解建议 |
|---|---|---|
| 凭证泄露 | .env 文件含敏感 Token,权限配置不当可能导致未授权访问 |
严格遵循 chmod 600,避免版本控制提交 |
| 误报疲劳 | 网络抖动或网关负载波动可能触发短暂告警 | 调整 ALERT_MULTIPLIER 和 RECOVER_MULTIPLIER 阈值 |
| 探测盲区 | 网关故障时延迟探测失效,可能遗漏真实 API 问题 | 叠加官方状态监控作为交叉验证 |
| 数据持久化 | 状态文件长期运行可能累积,需关注磁盘空间 | 定期清理或轮转日志文件 |
技能正文
name: claude-watchdog
description: Monitor the Claude API for outages and latency spikes with rich Telegram alerts. Status monitoring, latency probes, and automatic recovery notifications.
homepage: https://github.com/gisk0/claude-watchdog
metadata:
openclaw:
emoji: "🐕"
requires:
bins: [python3, crontab, curl]
env: [TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID, OPENCLAW_GATEWAY_TOKEN]
primaryEnv: TELEGRAM_BOT_TOKEN
Claude Watchdog 🐕
Monitor the Anthropic/Claude API for outages and latency spikes. Sends rich alerts to Telegram — no agent tokens consumed for status checks.
What It Does
Status Monitor (status-check.py)
status-check.py)- Polls
status.claude.comevery 15 minutes via cron - Alerts with incident name, latest update text, per-component status
- Tags incidents as "(not our model)" if e.g. Haiku is affected but you use Sonnet
- Sends all-clear on recovery
- Zero token cost
Latency Probe (latency-probe.py)
- Sends a minimal request through OpenClaw's local gateway every 15 minutes
- Measures real end-to-end latency to Anthropic API
- Maintains rolling baseline (median of last 20 samples)
- Alerts with 🟡/🟠/🔴 severity based on spike magnitude
- Sends all-clear when latency recovers
- ~$0.000001 per probe
Setup
Run the interactive setup script:
bash /path/to/skills/claude-watchdog/scripts/setup.sh
You'll need:
- Telegram Bot Token — from @BotFather
- Telegram Chat ID — send a message to your bot, then check
https://api.telegram.org/bot<TOKEN>/getUpdates - OpenClaw Gateway Token — run:
python3 -c "from pathlib import Path; import json; print(json.load(open(Path.home() / '.openclaw/openclaw.json'))['gateway']['auth']['token'])" - Gateway Port — default
18789
The setup script writes config, installs cron jobs, and runs an initial check.
To uninstall (removes cron jobs, optionally config/state):
bash /path/to/skills/claude-watchdog/scripts/setup.sh --uninstall
Config
Stored in ~/.openclaw/skills/claude-watchdog/claude-watchdog.env. To reconfigure, either re-run setup.sh or edit this file directly — changes take effect on the next cron run (within 15 minutes).
TELEGRAM_BOT_TOKEN=...
TELEGRAM_CHAT_ID=...
OPENCLAW_GATEWAY_TOKEN=...
OPENCLAW_GATEWAY_PORT=18789
MONITOR_MODEL=sonnet
PROBE_MODEL=openclaw
PROBE_AGENT_ID=main
| Variable | Default | Description |
|---|---|---|
TELEGRAM_BOT_TOKEN |
(required) | Telegram bot token from @BotFather |
TELEGRAM_CHAT_ID |
(required) | Target chat for alerts |
OPENCLAW_GATEWAY_TOKEN |
(required) | Auth token for the local OpenClaw gateway |
OPENCLAW_GATEWAY_PORT |
18789 |
Port the OpenClaw gateway listens on |
MONITOR_MODEL |
sonnet |
Model name to match in status incidents (e.g. "sonnet", "haiku") |
PROBE_MODEL |
openclaw |
Model alias sent to the gateway for latency probes. openclaw uses the gateway's default model routing |
PROBE_AGENT_ID |
main |
Value of the x-openclaw-agent-id header sent with probes |
FILTER_KEYWORDS |
(none) | Comma-separated keywords to filter out of status alerts (e.g. "skills,Artifacts,Memory"). Empty = receive all alerts |
Scripts also accept these as environment variables (env file takes priority).
Security Note
The env file contains sensitive tokens (Telegram bot token, gateway token). The setup script sets permissions to 600 (owner-only read/write). If you create or edit the file manually, ensure restricted permissions:
chmod 600 ~/.openclaw/skills/claude-watchdog/claude-watchdog.env
Alert Examples
Status incident:
🟠 Anthropic Status: Partially Degraded Service
📌 Elevated error rates on Claude 3.5 Haiku (not our model)
Status: Investigating
Update: "We are investigating increased error rates..."
Components:
🟠 API: partial outage
🔗 https://status.claude.com
Latency spike:
🟡 Anthropic API — High Latency Detected
Current: 12.3s
Baseline: 3.1s (median of last 19 samples)
Ratio: 4.0×
Slow responses are expected right now.
Recovery:
✅ Anthropic API — Latency Back to Normal
Current: 2.8s
Baseline: 3.1s
Was: 12.3s when alert fired
State & Logs
All state and log files are stored in ~/.openclaw/skills/claude-watchdog/:
| File | Purpose |
|---|---|
claude-watchdog-status.json |
Status check state |
claude-watchdog-latency.json |
Latency probe state & samples |
claude-watchdog-status.log |
Status check log |
claude-watchdog-latency.log |
Latency probe log |
Tuning Thresholds
Edit constants at the top of latency-probe.py:
| Constant | Default | Meaning |
|---|---|---|
ALERT_MULTIPLIER |
2.5 | Alert if latency > N× baseline median |
ALERT_HARD_FLOOR |
10.0s | Always alert above this absolute threshold |
RECOVER_MULTIPLIER |
1.5 | Clear alert when below N× baseline |
BASELINE_WINDOW |
20 | Rolling sample window size |
BASELINE_MIN_SAMPLES |
5 | Minimum samples before alerting starts |
PROBE_TIMEOUT |
45s | Give up on probe after this long |
Requirements
- Python 3.10+ (stdlib only, no pip dependencies)
- OpenClaw gateway running locally
- Telegram bot with access to the target chat
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。