轻量级beszel hub-agent监控搭建实现告警飞书通知
1. Beszel架构
1.1 逻辑角色划分
- beszel-hub:中心控制与展示节点,负责聚合状态、告警判定
- beszel-agent:部署在各被监控节点上,负责采集指标并与 hub 建立长连接
- feishu-proxy:告警转发组件,用于对接飞书 Webhook(格式问题)
1.2 通信关系总览
- hub 与 agent:双向通信(WebSocket / ssh)
- hub 与飞书:间接通信(通过 feishu-proxy)
2. 整体架构
graph TD
subgraph Monitoring
H[beszel-hub]
A1[beszel-agent
node-1]
A2[beszel-agent
node-2]
A3[beszel-agent
node-3]
end
subgraph Notification
F[feishu-proxy]
W[feishu-webhook]
end
H <--> A1
H <--> A2
H <--> A3
H -->|Alert Event| F
F -->|Webhook POST| W
3.download
4.install
4.1container
- https://hub.docker.com/u/henrygd
- https://hub.docker.com/r/henrygd/beszel-agent/tags
- https://hub.docker.com/r/henrygd/beszel

docker pull ghcr.io/henrygd/beszel/beszel:0.17
docker pull ghcr.io/henrygd/beszel/beszel-agent:0.17
docker pull ghcr.io/henrygd/beszel/beszel-agent-nvidia:0.17
1 | services: |
mac@GaGa beszel % docker-compose logs
beszel-agent | 2026/01/09 05:45:22 INFO Data directory path=/var/lib/beszel-agent
beszel-agent | 2026/01/09 05:45:22 INFO Detected root device name=vdb1
beszel-agent | 2026/01/09 05:45:22 INFO Detected network interface name=eth0 sent=12092022 recv=241918580
beszel-agent | 2026/01/09 05:45:22 INFO Detected network interface name=.orbmirror0 sent=872 recv=18086
beszel-agent | 2026/01/09 05:45:22 INFO WebSocket connected host=127.0.0.1:8090
beszel-hub | 2026/01/09 05:45:22 Server started at http://0.0.0.0:8090
beszel-hub | ├─ REST API: http://0.0.0.0:8090/api/
beszel-hub | └─ Dashboard: http://0.0.0.0:8090/_/
4.2binary
hub
cat > /etc/systemd/system/beszel-hub.service <<'EOF'
[Unit]
Description=Beszel Hub
After=network.target
[Service]
# 通过代理后访问beszel-hub
Environment="APP_URL=http://xxx.xxx.internal"
Type=simple
Restart=always
RestartSec=3
User=root
WorkingDirectory=/local/base/beszel-hub
ExecStart=/local/base/beszel-hub/beszel serve --http "0.0.0.0:10020"
[Install]
WantedBy=multi-user.target
EOF
agent
cat > /etc/systemd/system/beszel-agent.service <<'EOF'
[Unit]
Description=Beszel Agent Service
After=network-online.target
[Service]
# 从hub新增agent获取
Environment="LISTEN=45876"
Environment="KEY=xxxx"
Environment="HUB_URL=http://127.0.0.1:10020"
Environment="TOKEN=zzzz"
Type=simple
Restart=always
RestartSec=3
User=root
WorkingDirectory=/local/base/beszel-agent
ExecStart=/local/base/beszel-agent/beszel-agent
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now beszel-agent && systemctl status beszel-agent
4.3feishu-proxy
cat > /etc/systemd/system/feishu-proxy.service <<'EOF'
[Unit]
Description=feishu-proxy Service
After=network-online.target
[Service]
# feishu webhook
Environment="FEISHU_WEBHOOK=https://open.feishu.cn/open-apis/bot/v2/hook/xxx"
Type=simple
Restart=always
RestartSec=3
User=root
WorkingDirectory=/local/base/feishu-proxy
ExecStart=/local/base/feishu-proxy/feishu-proxy
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now feishu-proxy && systemctl status feishu-proxy
5.login && add agent
login
add agent

6.add notify
# 默认generic https
generic://ip:8000/feishu?type=interactive&title=高负载警告
# http
text: generic+http://你的代理域名:8000/feishu
post: generic+http://你的代理域名:8000/feishu?type=post&title=服务器警报
card: generic+http://你的代理域名:8000/feishu?type=interactive&title=高负载警告

