Skip to content

监控矩阵

状态:Roadmap

最后核对:2026-05-15

本文定义 NexusNet 未来的监控、审计和遥测平面。它是设计目标,不是当前已实现行为。

目标是让每个 agent 产生结构化观测数据,供以下能力使用:

  • 用户可见的系统状态检测。
  • 节点健康监测。
  • 网络性能监测。
  • SD-WAN 路径选择和故障切换。
  • 安全审计和被攻破迹象检测。
  • 长期 TimeDB / TimescaleDB 分析。

目标架构

text
agent runtime
  -> observability collector modules
  -> local bounded queue
  -> secure control stream MetricsReport frame
  -> backend telemetry ingest module
  -> hot status cache + audit event stream + TimeDB hypertables
  -> dashboard, health checks, SD-WAN decision engine, alerting

模块边界

组件规划模块职责
Agent collector rootnexus-agent/src/observability/mod.rs采集循环、本地队列、限速和打包。
Agent system collectornexus-agent/src/observability/system.rsCPU、内存、磁盘、进程、boot identity、binary measurement 和运行状态。
Agent network collectornexus-agent/src/observability/network.rs网卡、IP、DNS 视角、公网地址视角、路由表、socket/listener 状态。
Agent performance collectornexus-agent/src/observability/perf.rsRTT、jitter、丢包、吞吐、TCP_INFO、QUIC DATAGRAM、Noise 和 L3 metrics。
Agent security collectornexus-agent/src/observability/security.rsconfig hash、credential epoch、pin 校验、config replay/apply 状态、可疑事件和完整性信号。
Agent event packernexus-agent/src/observability/report.rs标准化事件为 protobuf envelope,并通过 secure control stream 发送。
Backend ingest rootnexus-backend/src/telemetry/mod.rs校验 report identity、去重、分类 severity,并分发到存储。
Backend status enginenexus-backend/src/telemetry/status.rs维护 dashboard 和健康 API 使用的当前状态。
Backend TimeDB writernexus-backend/src/telemetry/timedb.rs写入 TimescaleDB。
Backend audit bridgenexus-backend/src/telemetry/audit.rs把安全和控制面观测转换为持久 audit entry。
SD-WAN signal buildernexus-backend/src/telemetry/sdwan.rs为路径选择和故障切换生成评分输入。

gRPC Envelope

现有 secure control stream 已经有 SECURE_FRAME_KIND_METRICS_REPORT。未来应扩展 MetricsReport 为带版本的 observability envelope,不新增未认证通道。

规划形状:

protobuf
message ObservabilityReport {
  string node_id = 1;
  uint64 sequence = 2;
  google.protobuf.Timestamp collected_at = 3;
  string schema_version = 4;
  string agent_version = 5;
  string config_hash = 6;
  uint64 config_version = 7;
  string credential_epoch = 8;
  repeated Observation observations = 9;
}

message Observation {
  string id = 1;
  string category = 2;       // system, network, performance, security, audit
  string subject_type = 3;   // node, link, listener, route, upstream, credential
  string subject_id = 4;
  string severity = 5;       // debug, info, warn, critical
  google.protobuf.Timestamp observed_at = 6;
  map<string, string> labels = 7;
  bytes payload_json = 8;
}

规则:

  • Report 只通过加密 secure control stream 发送。
  • node_idsequenceconfig_hashcredential_epoch 必填。
  • backend 必须按 active control session 拒绝过期或重放 sequence。
  • payload 由 categorysubject_type 定型;backend 保存 raw JSON,并抽取索引字段进入 typed tables。
  • report 必须有上限。大对象要采样、截断,或在后续诊断 artifact 设计中发送。

数据矩阵

安全和审计信号

信号Labels字段用途
Config appliedconfig_version, config_hash, signature_idapply result、listener hash、route hash、duration发现 stale config、发布失败、回滚。
Config replay stateconfig_version, config_hash, replay_sourcerequested version、applied hash、duplicate skipped、replay latency、backend session id hash重启恢复、stale config 检测和发布审计。
Credential epochcredential_epoch, credential_ids_hashactive key ids hash、revoked key ids hash、next rotation time吊销和 stale key 检测。
SPKI pin validationupstream_id, pin_id, transportexpected pins、observed SPKI SHA-256、result、peer address检测 agent 到 upstream 之间的 MITM。
REALITY validationcredential_id, server_name, short_id, listeneraccept/reject reason、target host、protocol、peer addressREALITY 滥用检测和路由审计。
Noise handshakecredential_id, listener, peer_node_idresult、handshake duration、rekey count、error kind检测 Noise 失败尖峰或 stale key。
Control sessionsession_id_hash, psk_fingerprintopen/close reason、sequence window、rekey age发现重复会话、重放、异常断连。
Node identity driftnode_idboot id hash、machine id hash、binary hash、public IP/ASN、region发现克隆节点或异常迁移。
Integrity signalbinary_hash, config_hashprocess start time、executable path hash、container image digest发现 agent binary 被替换或运行环境异常。
Operator action echoaudit_id, resource_typeapplied version、node ack set、failed node set关联用户操作和分布式 apply 状态。

系统状态信号

信号Labels字段用途
Node resource snapshotnode_idCPU、memory、load average、uptime、process RSS、fd count节点健康和容量规划。
Disk statemountfree bytes、inode pressure、read-only flag发现主机存储压力和 agent 不稳定。
Process statepid, agent_versionrestart count、panic count、last error class、runtime thread countAgent 健康状态。
Clock statenode_idwall clock offset、monotonic drift estimate、NTP sync stateTLS/REALITY 有效期和日志排序。
Capability reportfeaturesupported、enabled、reason、kernel versionDCO、GSO/GRO、TUN、QUIC DATAGRAM 能力。
Listener statetransport, listen_addr, listen_portbound、owner、route count、policy hash、bind error端口冲突和路由状态。

网络状态信号

信号Labels字段用途
Interface snapshotifnameaddresses、MTU、carrier、rx/tx counters、drops、errors链路健康和 SD-WAN 可用性。
Route table snapshottable, ifnamedefault route、route count、managed route hash发现 route drift 和 L3 apply 失败。
Public address viewsourceobserved IPv4/IPv6、ASN、region、changed flag节点可达性和克隆检测。
DNS viewresolveranswer set hash、latency、failure rate发现 DNS 污染或地域差异。
Peer reachabilitypeer_node_id, transportreachable、last success、failure reason、NAT observationSD-WAN peer graph。
Upstream reachabilityupstream_id, transportconnect success、error class、observed peer cert pin源站健康和 MITM 检测。

网络性能信号

信号Labels字段用途
Peer link metricpeer_node_id, transportRTT、jitter、packet loss、throughput estimateSD-WAN path score。
TCP_INFO snapshotlistener, upstreamsrtt、rttvar、cwnd、retrans、pmtuTCP 路径质量和拥塞判断。
QUIC connection metricroute_id, upstreamhandshake time、RTT、loss、cwnd、datagram sent/received/droppedQUIC REALITY path score。
Noise session metricpeer_node_idhandshake duration、packets、bytes、decrypt failuresUDP ENC 健康。
L3 tunnel metricnetwork_id, endpoint_id, peer_endpoint_idpackets、bytes、drops、MTU errors、route installsL3 健康和路由决策。
Listener route metricchain_id, listeneractive connections、total connections、errors、bytes in/out容量和策略调优。
Health probe metricupstream_idTCP connect time、TLS pin result、REALITY result源站选择和告警。

用户可见状态信号

状态输入输出
Node statuscontrol session、resource snapshot、config ack、listener stateonline、degraded、offline、maintenance、compromised-suspected
Link statuspeer reachability、RTT、loss、jitter、QUIC/Noise errorshealthy、degraded、unstable、down
Upstream statusreachability、pin validation、route errors、health probeshealthy、degraded、pin-mismatch、unreachable
Security statuspin mismatch、identity drift、stale credential epoch、config replay mismatchnormal、suspicious、compromised-suspected
SD-WAN scorelatency、loss、jitter、throughput、stability、security flagsnumeric route score and reason codes

TimeDB 存储计划

backend compose 中已有 postgres-timescale 服务用于未来 metrics。ingest 模块应区分当前状态表和时序 hypertables。

规划 hypertables:

HypertableTime column主要维度示例
node_metric_tstimenode_id, metricCPU、memory、disk、process counters。
link_metric_tstimenode_id, peer_node_id, transportRTT、jitter、loss、throughput。
listener_metric_tstimenode_id, transport, listen_addr, listen_portroute counts、active connections、errors。
route_metric_tstimenode_id, route_id, chain_id, network_idbytes、packets、connection count。
security_event_tstimenode_id, event_type, severitypin mismatch、identity drift、stale config。
probe_result_tstimenode_id, target_id, probe_typeTCP connect、TLS pin、REALITY、DNS。
sdwan_score_tstimesrc_node_id, dst_node_id, transportscore、selected path、reason codes。

保留策略:

  • 高频 raw samples:7-14 天。
  • 1 分钟 rollups:30-90 天。
  • security events 和 audit-derived records:按 audit 策略保留。

Backend 处理流水线

规划 ingest 流程:

  1. 解密 SecureFrame
  2. 解码 ObservabilityReport
  3. 校验 node identity、active session、sequence、config hash 和 schema version。
  4. (node_id, sequence, observation_id) 去重。
  5. 更新 hot status cache。
  6. 写入 TimeDB。
  7. 将安全观测转换成 audit log entry。
  8. 输出 SD-WAN 决策输入。

backend 不能只信节点自报的 compromise signals。安全状态必须结合 self-report、cross-node probes 和 backend-side facts。

跨节点验证

为了检测 MITM 或异常路径,backend 应调度独立 probe:

  • 要求多个节点观测同一个 upstream SPKI pin。
  • 跨区域比较 DNS answers 和 public address views。
  • 比较 REALITY handshake result 和目标行为。
  • 当只有某个节点观测到不同 pin 或路由行为时,将该节点标记为 suspicious。

跨节点验证是检测层,不替代 TPM 或 remote attestation。

安全要求

  • Telemetry 中绝不发送明文私钥或 PSK。
  • 不需要精确值时使用 hash id。
  • 不能过度脱敏影响功能;SD-WAN 和健康检测经常需要精确 endpoint 地址。
  • agent telemetry 在和控制面状态、跨节点观测对齐前都视为不可信输入。
  • 安全观测必须包含足够审计上下文,但不能包含 secret material。

实施阶段

阶段状态工作
1. Schema and modules规划增加 agent observability 模块、backend telemetry 模块和 versioned report protobuf。
2. Config replay audit规划上报 config hash、signature id、replay/apply state、listener hash 和 apply result。
3. Security pins规划上报 SPKI pin validation result 和 pin mismatch event。
4. System and listener status规划上报 resource snapshot、listener bind state、route counts 和 capability report。
5. Network performance规划上报 peer link、TCP_INFO、QUIC、Noise、L3 和 health probe metrics。
6. TimeDB ingest规划增加 TimescaleDB hypertables、retention 和 rollup policy。
7. SD-WAN signals规划从 TimeDB/current status 生成 route score inputs。
8. Attestation-ready signals规划增加 boot id、binary hash、image digest、TPM measurement placeholders 和 trust-level scoring。

NexusNet documentation