Files
Distributed-Prometheus/doc/ARCHITECTURE.md
Super User 72a5bf30b4 feat: 天地图瓦片缓存(tile-cache)、拓扑标注助手与文档更新
- tile-cache: 瓦片缓存服务(vec/cva)、启动探针、详细日志、上游超时可配置(UPSTREAM_TIMEOUT_MS)
- central: docker-compose 集成 tile-cache,env.example 增加 TILE_CACHE_* / TIANDITU_TK
- topology-editor: 天地图/缓存加载、GPS 安全来源错误提示、TIANDITU 文档(403/白名单、localhost 测试说明)
- doc: README 部署步骤与 GPS 安全来源说明,TIANDITU_CONFIG 完善

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-25 11:11:38 -05:00

228 lines
12 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 系统架构图
## 容器关系图
```
┌─────────────────────────────────────────────────────────────────┐
│ 边缘节点 (Edge Agents) │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Edge Node 1 │ │ Edge Node 2 │ │ Edge Node N │ │
│ │ │ │ │ │ │ │
│ │ Prometheus │ │ Prometheus │ │ Prometheus │ │
│ │ Edge │ │ Edge │ │ Edge │ │
│ │ │ │ │ │ │ │
│ │ ONVIF │ │ ONVIF │ │ ONVIF │ │
│ │ Exporter │ │ Exporter │ │ Exporter │ │
│ │ │ │ │ │ │ │
│ │ Blackbox │ │ Blackbox │ │ Blackbox │ │
│ │ Exporter │ │ Exporter │ │ Exporter │ │
│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
│ │ │ │ │
│ └──────────────────┼──────────────────┘ │
│ │ │
│ remote_write │
│ (HTTP POST) │
└────────────────────────────┼────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ 中央服务器 (Central Server) │
│ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ VictoriaMetrics (8428) │ │
│ │ ┌────────────────────────────────────────────────────┐ │ │
│ │ │ 远程写入接收器 │ │ │
│ │ │ - 接收边缘节点推送的指标数据 │ │ │
│ │ │ - 存储时序数据 │ │ │
│ │ │ - 提供查询接口 │ │ │
│ │ └────────────────────────────────────────────────────┘ │ │
│ └────────────────────┬───────────────────────────────────────┘ │
│ │ │
│ │ 数据查询 │
│ │ │
│ ┌────────────────────▼───────────────────────────────────────┐ │
│ │ Prometheus Central (9091) │ │
│ │ ┌────────────────────────────────────────────────────┐ │ │
│ │ │ 指标收集和查询引擎 │ │ │
│ │ │ - 从 VictoriaMetrics 读取数据 │ │ │
│ │ │ - 抓取本地服务指标 (自身、Grafana、Alertmanager) │ │ │
│ │ │ - 评估告警规则 │ │ │
│ │ │ - 提供 PromQL 查询接口 │ │ │
│ │ └────────────────────────────────────────────────────┘ │ │
│ └────────────┬───────────────────────────┬───────────────────┘ │
│ │ │ │
│ │ 告警触发 │ 数据查询 │
│ │ │ │
│ ┌────────────▼──────────┐ ┌─────────────▼──────────────┐ │
│ │ Alertmanager (9093) │ │ Grafana (3000) │ │
│ │ ┌──────────────────┐ │ │ ┌──────────────────────┐ │ │
│ │ │ 告警管理 │ │ │ │ 可视化仪表板 │ │ │
│ │ │ - 接收告警 │ │ │ │ - 从 Prometheus 查询 │ │ │
│ │ │ - 告警分组 │ │ │ │ - 创建图表和仪表板 │ │ │
│ │ │ - 发送通知 │ │ │ │ - 多用户管理 │ │ │
│ │ │ - 告警抑制 │ │ │ │ - 中文界面 │ │ │
│ │ └──────────────────┘ │ │ └──────────────────────┘ │ │
│ └───────────────────────┘ │ └──────────────────────────┘ │
│ │ │
└──────────────────────────────┼──────────────────────────────────┘
│ HTTP 访问
┌───────────────┼───────────────┐
│ │ │
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ 管理员 │ │ 用户组A │ │ 用户组B │
│ (Admin) │ │ (Org A) │ │ (Org B) │
└─────────────┘ └─────────────┘ └─────────────┘
```
## 数据流向
### 1. 数据收集流程
```
边缘节点设备
├─ ONVIF 设备 (摄像头等)
│ └─> ONVIF Exporter ──┐
│ │
├─ 网络设备 (IP地址) │
│ └─> Blackbox Exporter ─┤
│ │
└─> Prometheus Edge ───────┘
│ remote_write (HTTP POST)
VictoriaMetrics (8428)
│ 数据存储
Prometheus Central (9091)
├─> 告警规则评估
│ └─> Alertmanager (9093)
└─> 数据查询
└─> Grafana (3000)
```
### 2. 告警流程
```
设备异常
Prometheus 检测到指标异常
告警规则触发 (alert_rules.yml)
发送告警到 Alertmanager
Alertmanager 处理告警
├─> 告警分组
├─> 告警抑制
└─> 发送通知 (webhook/邮件等)
```
### 3. 查询流程
- **中央自抓指标**Grafana → Prometheus 数据源 → Prometheus 返回结果。
- **边缘数据**Grafana → **VictoriaMetrics** 数据源 → VictoriaMetrics 返回结果(不经过 Prometheus 查询 VM
## 容器详细说明
### 1. VictoriaMetrics (8428)
- **作用**:远程写入接收器,存储时序数据
- **接收**:边缘节点通过 `remote_write` 推送的数据
- **提供**:数据查询接口
- **数据路径**`/storage/victoria-metrics-data`
### 2. Prometheus Central (9091)
- **作用**:指标收集、查询和告警评估
- **数据源**
- 从 VictoriaMetrics 读取边缘节点数据(用于告警规则评估与部分查询)
- 抓取本地服务自身、Grafana、Alertmanager、VictoriaMetrics
- **功能**
- 评估告警规则 (`alert_rules.yml`)
- 提供 PromQL 查询接口
- 发送告警到 Alertmanager
- **数据路径**`/storage/prometheus-data`
### 3. Alertmanager (9093)
- **作用**:告警管理和通知
- **接收**:来自 Prometheus 的告警
- **功能**
- 告警分组和去重
- 告警抑制
- 发送通知当前配置webhook `http://127.0.0.1:5001/`
### 4. Grafana (3000)
- **作用**:数据可视化和仪表板
- **数据源****Prometheus**(中央自抓指标)、**VictoriaMetrics**(边缘推送数据;查边缘 Ping/ONVIF 等请选此数据源)
- **功能**
- 创建图表和仪表板
- 多用户管理(组织隔离)
- 中文界面
- 权限控制
- **数据路径**`/storage/grafana-data`
## 网络关系
```
monitoring_net (Docker Bridge Network)
├─ prometheus-central:9090 (内部)
│ └─> 映射到宿主机:9091
├─ grafana:3000 (内部)
│ └─> 映射到宿主机:3000
├─ alertmanager:9093 (内部)
│ └─> 映射到宿主机:9093
└─ victoria-metrics:8428 (内部)
└─> 映射到宿主机:8428
```
## 端口映射
| 容器 | 内部端口 | 外部端口 | 用途 |
|------|---------|---------|------|
| Prometheus | 9090 | 9091 | PromQL 查询和 Web UI |
| Grafana | 3000 | 3000 | 可视化仪表板 |
| Alertmanager | 9093 | 9093 | 告警管理界面 |
| VictoriaMetrics | 8428 | 8428 | 远程写入和查询接口 |
## 数据存储
所有数据存储在 `/storage` 分区:
```
/storage/
├── prometheus-data/ # Prometheus 时序数据
├── grafana-data/ # Grafana 配置和仪表板
├── victoria-metrics-data/ # VictoriaMetrics 时序数据
└── docker/ # Docker 数据
```
## 依赖关系
```
VictoriaMetrics
↑ (数据查询)
Prometheus
├─> (告警触发) ──> Alertmanager
└─> (数据查询) ──> Grafana
```
**启动顺序**
1. VictoriaMetrics数据存储
2. Prometheus依赖 VictoriaMetrics
3. Alertmanager接收 Prometheus 告警)
4. Grafana查询 Prometheus 数据)