香港服务器部署Uptime Kuma:网站可用性监控 + 多渠道告警 + 状态页完整配置
当你的网站挂了,是用户第一个发现还是你自己第一个发现?Uptime Kuma 是一款开源的自托管监控工具,每隔 30 秒检测你的网站、API、数据库是否正常,一旦异常立即通过飞书/Telegram/邮件通知到你。相比 Pingdom($15/月起)和 UptimeRobot(有检测频率限制),Uptime Kuma 完全免费、检测频率可设为 20 秒、支持公开状态页,在香港服务器上部署后监控全球服务不受限制。
一、Uptime Kuma vs 竞品对比
| 维度 | Uptime Kuma(自托管) | UptimeRobot(免费版) | Pingdom(付费) |
|---|---|---|---|
| 费用 | 免费(仅服务器成本) | 免费(有限制) | $15/月起 |
| 最小检测间隔 | 20秒 | 5分钟 | 1分钟 |
| 监控数量 | 无限制 | 50个 | 按计划 |
| 状态页 | ✅ 自定义域名 | ✅ | ✅ |
| SSL 到期监控 | ✅ | ❌(付费才有) | ✅ |
| 数据隐私 | 完全自主 | 在 UptimeRobot 服务器 | 在 Pingdom 服务器 |
| 告警渠道 | 90+种(含飞书/钉钉) | 有限 | 有限 |
二、Docker 部署 Uptime Kuma
<code"># 创建数据目录 mkdir -p /opt/uptime-kuma # 启动容器 docker run -d \ --name uptime-kuma \ --restart unless-stopped \ -p 127.0.0.1:3001:3001 \ -v /opt/uptime-kuma:/app/data \ louislam/uptime-kuma:latest # 查看启动状态 docker logs uptime-kuma | tail -20 # 首次访问:http://服务器IP:3001(通过 Nginx 反代后为 https://status.yourdomain.com)
<code"># Nginx 反向代理
# /etc/nginx/sites-available/status.yourdomain.com
server {
listen 443 ssl http2;
server_name status.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/status.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/status.yourdomain.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
certbot --nginx -d status.yourdomain.com
systemctl reload nginx三、添加监控项(常用类型)
登录 Uptime Kuma Dashboard → 点击「Add New Monitor」
HTTP(s) 监控(网站/API)
<code"> 配置项: - Monitor Type: HTTP(s) - Friendly Name: 官网首页 - URL: https://yourdomain.com - Heartbeat Interval: 60秒(可设最低20秒) - Retries: 3(连续3次失败才告警,避免偶发误报) - Accepted Status Codes: 200-299 高级选项: - Keyword: (可填页面必须包含的关键词,如"立即购买") - SSL Certificate Expiry Notification: 30天前提醒
TCP 端口监控(数据库/Redis)
<code"> - Monitor Type: TCP Port - Host: 127.0.0.1(或数据库服务器IP) - Port: 3306(MySQL)/ 6379(Redis)/ 5432(PostgreSQL) - Heartbeat Interval: 60秒
DNS 监控(域名解析)
<code"> - Monitor Type: DNS - Hostname: yourdomain.com - Resolver Server: 8.8.8.8 - Record Type: A - Expected Value: 你的服务器IP (DNS 被劫持时立即告警)
Docker 容器监控
<code"> - Monitor Type: Docker Container - Container Name / ID: nginx(直接监控容器状态) - Docker Daemon: /var/run/docker.sock
四、飞书告警配置
<code"> 1. 在飞书群中添加自定义机器人: 群设置 → 群机器人 → 添加机器人 → 自定义机器人 → 记录 Webhook URL 2. Uptime Kuma → Settings → Notifications → Add Notification - Notification Type: Feishu(飞书) - Feishu Webhook URL: https://open.feishu.cn/open-apis/bot/v2/hook/xxxxx 3. 点击「Test」发送测试消息验证是否收到 4. 在每个监控项中启用该通知渠道
告警消息示例
<code"> ⬇️ [官网首页] 不可用 时间:2026-07-28 03:42:15 原因:Connection refused 响应时间:超时 ⬆️ [官网首页] 已恢复 时间:2026-07-28 03:45:30 停机时长:3分15秒
五、Telegram 告警配置
<code">
1. 创建 Telegram Bot:
- 在 Telegram 中找 @BotFather
- 发送 /newbot,按提示创建并获取 Bot Token
2. 获取 Chat ID:
- 将 Bot 加入目标群组或私聊
- 访问:https://api.telegram.org/bot{TOKEN}/getUpdates
- 在返回的 JSON 中找到 chat.id
3. Uptime Kuma → Notifications → Add
- Type: Telegram
- Bot Token: xxxxx
- Chat ID: -100xxxxxxxxx(群组为负数)
六、搭建公开状态页
<code"> Status Page 适合对外展示服务健康状态,减少客服压力 操作路径: Status Pages → Add New Status Page 配置项: - Slug(URL路径): status(访问 https://status.yourdomain.com/status) - Title: 后浪云 服务状态 - Description: 实时监控我们的服务可用性 添加监控组: - 官网服务:包含 首页、API、控制面板 - 基础设施:包含 香港机房、新加坡机房 自定义域名(需要额外 Nginx 配置): - Custom Domain: status.yourdomain.com - 让外部用户访问此页面了解服务状态
七、监控香港服务器本身
<code"># Uptime Kuma 也可以监控服务器自身指标 # 通过 Push 模式(服务器主动 ping 监控端)实现 # 1. 在 Uptime Kuma 添加 Push 类型监控 # → 获得唯一的 Push URL,例如: # https://status.yourdomain.com/api/push/abcde12345?status=up&msg=OK # 2. 在被监控服务器上设置定时任务 cat >> /etc/crontab << 'EOF' * * * * * root curl -fsS "https://status.yourdomain.com/api/push/abcde12345?status=up&msg=OK&ping=" > /dev/null 2>&1 EOF # 如果服务器宕机,crontab 停止运行,Uptime Kuma 60秒内检测到 Push 超时并告警
八、批量导入监控项
<code"># 通过 Uptime Kuma API 批量创建监控(适合管理几十个服务)
curl -X POST https://status.yourdomain.com/api/v1/monitor \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your_api_token" \
-d '{
"type": "http",
"name": "API健康检查",
"url": "https://api.yourdomain.com/health",
"interval": 60,
"retryInterval": 60,
"maxretries": 3,
"notificationIDList": {"1": true}
}'
# 查看所有监控项
curl https://status.yourdomain.com/api/v1/monitor \
-H "Authorization: Bearer your_api_token"九、告警降噪最佳实践
| 问题 | 解决方案 | 配置项 |
|---|---|---|
| 偶发网络抖动误报 | 增加重试次数 | Retries: 3 |
| 维护窗口频繁告警 | 设置维护计划 | Maintenance → Add |
| 同一问题反复通知 | 设置重复告警间隔 | Resend Notification: 1小时 |
| 夜间非工作时间告警 | 分级:严重立即通知,一般早上通知 | 多个通知渠道分配 |
十、总结
Uptime Kuma 在香港服务器上部署后,从香港节点检测全球服务的网络延迟和可用性,比从大陆节点检测更接近国际用户的真实体验。告警响应时间最快 20 秒,配合飞书群机器人,服务异常时整个团队秒收通知,运维响应效率大幅提升,是每个香港服务器用户必装的基础监控工具。