Files
nexus/wiki/concepts/合成监控.md

63 lines
2.9 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.
---
title: "合成监控"
type: concept
aliases: [Synthetic Monitoring, 合成监测, Active Monitoring, 主动监控, Blackbox Monitoring]
tags: [monitoring, uptime, http, tls, proactive]
date: 2025-11-11
---
# 合成监控
## Overview
合成监控Synthetic Monitoring也称为主动监控Active Monitoring或黑盒监控Blackbox Monitoring是通过模拟真实用户请求或系统调用从外部视角主动探测服务可用性和响应质量的监控方法。与基于主机/应用内部指标的白盒监控Whitebox Monitoring互补共同构成完整的可观测性覆盖。
## Core Principles
- **主动探测**:不依赖服务内部指标,从外部发起请求
- **故障预判**:在用户发现前检测到服务异常
- **SLA 验证**:客观量化服务可用性和响应时间
- **全球分布**:从多个地理位置探测(定位区域性故障)
- **可重复**:周期性自动执行,历史可追溯
## Key Dimensions
| 维度 | 指标 | 告警阈值示例 |
|------|------|------------|
| 可用性 | `probe_success == 0` | 连续 2 次失败 |
| 响应时间 | `probe_duration_seconds > 5` | > 5s |
| HTTP 状态码 | `probe_http_status_code >= 400` | 非 2xx |
| TLS 证书 | `probe_ssl_earliest_cert_expiry - time() < 14d` | < 14 天 |
| DNS 解析 | `probe_dns_lookup_duration_seconds > 1` | > 1s |
## Tools for Synthetic Monitoring
| 工具 | 类型 | 特点 |
|------|------|------|
| [[blackbox_exporter]] | Prometheus Exporter | HTTP/TCP/DNS/TLS 探测PromQL 告警 |
| [[Uptime Kuma]] | 自托管 SaaS 替代 | Web UI 友好Docker 部署 |
| UptimeRobot | SaaS | 全球节点,免维护 |
| Pingdom | SaaS | 企业级 SLA 监控 |
| Grafana Synthetic Monitoring | Grafana Cloud | Grafana 生态集成 |
## Blackbox vs Whitebox Monitoring
| 维度 | 黑盒(合成监控) | 白盒(内部监控) |
|------|----------------|----------------|
| 数据来源 | 外部请求 | 内部指标 |
| 故障感知 | 用户视角的故障 | 基础设施故障 |
| 配置复杂度 | 低 | 中 |
| 覆盖范围 | HTTP/TCP 层 | CPU/内存/应用层 |
| 适用场景 | SLA 验证、可用性告警 | 根因分析、性能诊断 |
## Home Server Use Cases
1. **外网服务探测**:检测 NAS / n8n / Grafana 等内网服务的公网访问可用性
2. **TLS 证书监控**:提前发现即将到期的证书,避免生产事故
3. **内网域名解析**:监控 DNS 解析是否正常frp 隧道故障检测)
4. **API 健康检查**:检测第三方 API 服务的可用性OpenAI / Claude API
## Related Entities
- [[blackbox_exporter]] — Prometheus 合成监控实现
- [[Uptime Kuma]] — 互补的合成监控工具
## Related Concepts
- [[System Monitoring]] — 上游领域
- [[Prometheus告警规则]] — 合成监控告警条件
- [[PromQL]] — 探测指标查询语言
- [[时序数据库]] — 探测数据存储