可观测性三大支柱架构
Architecture
可观测性架构图,实现三大支柱(指标、追踪、日志),包括 OpenTelemetry SDK 埋点、OTLP 收集器管道、Prometheus、Jaeger 和 Loki 后端、Grafana 仪表板、SLO/SLI 跟踪和 PagerDuty 告警集成。该模板提供完整的可观测性技术栈参考,展示遥测数据如何从应用埋点流经收集、存储、可视化到事件响应。对于构建生产监控基础设施的 SRE 团队至关重要。
完整 FlowZap 代码
Application { # Application Services
n1: rectangle label:"Service A"
n2: rectangle label:"Service B"
n3: rectangle label:"Service C"
n4: rectangle label:"OpenTelemetry SDK"
n1.handle(bottom) -> n4.handle(top) [label="Instrument"]
n2.handle(bottom) -> n4.handle(top) [label="Instrument"]
n3.handle(bottom) -> n4.handle(top) [label="Instrument"]
n4.handle(bottom) -> Collector.n5.handle(top) [label="OTLP Export"]
}
Collector { # OpenTelemetry Collector
n5: rectangle label:"Receive Telemetry"
n6: rectangle label:"Process and Batch"
n7: rectangle label:"Export Metrics"
n8: rectangle label:"Export Traces"
n9: rectangle label:"Export Logs"
n5.handle(right) -> n6.handle(left) [label="Pipeline"]
n6.handle(right) -> n7.handle(left) [label="Metrics"]
n6.handle(bottom) -> n8.handle(top) [label="Traces"]
n6.handle(bottom) -> n9.handle(top) [label="Logs"]
n7.handle(bottom) -> Backends.n10.handle(top) [label="Prometheus"]
n8.handle(bottom) -> Backends.n11.handle(top) [label="Jaeger"]
n9.handle(bottom) -> Backends.n12.handle(top) [label="Loki"]
}
Backends { # Observability Backends
n10: rectangle label:"Prometheus (Metrics)"
n11: rectangle label:"Jaeger (Distributed Traces)"
n12: rectangle label:"Loki (Log Aggregation)"
n13: rectangle label:"Alertmanager"
n10.handle(right) -> n13.handle(left) [label="Alert Rules"]
n10.handle(bottom) -> Visualization.n14.handle(top) [label="PromQL"]
n11.handle(bottom) -> Visualization.n14.handle(top) [label="Trace ID"]
n12.handle(bottom) -> Visualization.n14.handle(top) [label="LogQL"]
}
Visualization { # Visualization & Alerting
n14: rectangle label:"Grafana Dashboard"
n15: rectangle label:"SLO/SLI Tracking"
n16: rectangle label:"Incident Response"
n17: rectangle label:"PagerDuty / Slack"
n14.handle(right) -> n15.handle(left) [label="SLO Burn Rate"]
n15.handle(right) -> n16.handle(left) [label="SLO Breach"]
n16.handle(right) -> n17.handle(left) [label="Alert"]
n13.handle(bottom) -> Visualization.n17.handle(top) [label="Fire Alert"]
}
为什么需要这个工作流?
Monitoring alone (dashboards and alerts) tells you something is wrong but not why. The three pillars of observability—metrics, traces, and logs—provide the complete picture: metrics detect anomalies, traces pinpoint which service in a request chain is slow, and logs reveal the specific error details.
工作原理
- Step 1: Application services are instrumented with the OpenTelemetry SDK.
- Step 2: Telemetry data (metrics, traces, logs) is exported via OTLP to the OpenTelemetry Collector.
- Step 3: The collector processes, batches, and routes data to specialized backends.
- Step 4: Prometheus stores metrics, Jaeger stores distributed traces, and Loki stores logs.
- Step 5: Grafana dashboards provide unified visualization across all three pillars.
- Step 6: SLO/SLI tracking and Alertmanager trigger PagerDuty alerts when error budgets are consumed.
替代方案
Vendor-specific solutions (Datadog, New Relic) provide all-in-one observability but at significant cost. ELK stack handles logs but not traces natively. This template shows the open-source observability stack with OpenTelemetry.
Key Facts
| Template Name | 可观测性三大支柱架构 |
| Category | Architecture |
| Steps | 6 workflow steps |
| Format | FlowZap Code (.fz file) |
相关模板
微服务 API 网关架构
Architecture
微服务 API 网关架构图,展示请求路由、JWT 身份验证、速率限制、服务发现以及跨分布式后端服务的响应聚合。该模板模拟微服务生态系统中所有客户端流量的入口点,在请求到达内部服务之前执行安全策略。适合设计具有集中式横切关注点的可扩展 API 基础设施的平台工程师。
微服务每服务独立数据库架构
Architecture
每服务独立数据库架构图,每个微服务拥有其专用数据存储,通过 Kafka 进行事件驱动同步以实现跨服务数据一致性。该模板展示了微服务数据隔离的核心原则,展示 PostgreSQL 和 MongoDB 如何在多语言持久化策略中共存。对于在保持最终一致性的同时强制服务自治的架构师至关重要。
按业务能力分解微服务架构
Architecture
按业务能力组织的微服务分解架构图:身份认证、产品目录、定价和订单履行,每个都有独立的数据存储和 API。该模板展示如何将单体应用拆分为与业务领域对齐的服务,使用 Backend-for-Frontend (BFF) 模式进行客户端特定的聚合。适合规划领域驱动微服务边界的架构师。
微服务绞杀者模式迁移架构
Architecture
绞杀者模式迁移架构图,展示使用路由层在新旧系统之间分流流量,逐步用新微服务替换遗留单体应用。该模板模拟经过验证的迁移策略,新功能作为微服务构建,遗留端点逐步退役。对于在不进行高风险大爆炸重写的情况下现代化遗留系统的团队至关重要。