- 中央:config/(prometheus,alertmanager,grafana)、apps/(tile-cache,topology-editor) - 边缘:config/(vmagent,blackbox,targets)、apps/(onvif-exporter) - env: TRAEFIK_PROVIDER、prometheus/env.example 详细说明 - 文档:README/doc 重构,EDGE_CACHE 合并到 EDGE_AGENT_CONFIG - targets.csv 更新流程说明,ARCHITECTURE 图收窄 Made-with: Cursor
3.1 KiB
3.1 KiB
边缘节点配置文件说明
需要什么
| 类型 | 说明 | 对应组件 |
|---|---|---|
| 必选 | remote_write 推送到中央 | prometheus-edge |
| 必选 | Ping/网络探测 | blackbox-exporter |
| 可选 | ONVIF 等 | onvif-exporter(--profile onvif),见 ONVIF_ALTERNATIVES.md |
容器与数据流
| 容器 | 作用 | 端口 |
|---|---|---|
| prometheus-edge (vmagent) | 抓取 Blackbox(及可选 ONVIF),remote_write → 中央 VictoriaMetrics,含内存+磁盘缓存 | 9092 |
| blackbox-exporter | Ping/HTTP/TCP 探测 | 9115(内部) |
| onvif-exporter | 可选,ONVIF 探测 | 9600(内部) |
数据流:目标 → Exporter → prometheus-edge → remote_write → 中央 VictoriaMetrics。
目录与配置
- config/targets.csv:统一监控目标(ping/onvif/topology),格式与脚本见 TARGETS_AND_MONITORING.md。
- config/update-configs.sh:从 targets.csv 生成
target-onvif.json、target-ping.json、target-topology.geojson。 - prometheus-edge (vmagent):使用
config/vmagent/vmagent-scrape.yml.template抓取;CENTRAL_SERVER_HOST/PORT来自.env;磁盘缓存卷vmagent-cache-data。 - .env:
CENTRAL_SERVER_HOST、CENTRAL_SERVER_PORT=8428、EDGE_NODE_ID。本机同机用./deploy.sh --local;跨机配.env后./deploy.sh。
常用操作
- 改监控目标:编辑
config/targets.csv→cd config && ./update-configs.sh;vmagent 每 5 分钟自动重载 JSON,无需重启。 - 改中央地址:编辑
.env→docker compose restart prometheus-edge。
中心宕机 / 断网时的缓存
docker-compose.yaml 使用 vmagent 实现:
| 层级 | 机制 | 说明 |
|---|---|---|
| 短时内存缓存 | 内存队列 | 中心短暂不可达时在内存中缓冲(约 30 分钟量级) |
| 长时磁盘缓存 | 持久化队列 | 长时间离线写入磁盘(默认 512MB),恢复后自动补传 |
| 冗余重试 | 失败重试 | 边缘重启后从磁盘恢复未上传数据 |
参数(修改 prometheus-edge 的 command 可调):-remoteWrite.maxDiskUsagePerURL=512MB、-remoteWrite.tmpDataPath=/cache/remotewrite、-memory.allowedPercent=80。监控指标:vmagent_remotewrite_pending_bytes、vmagent_remotewrite_packets_dropped_total。