2026-10-08 16:48:05 +08:00
<!DOCTYPE html>
< html lang = "zh-CN" data-theme = "light" >
< head >
< meta charset = "utf-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1" >
< title > SLI / SLO / 错误预算 · 阶段 3 模块 1 · SRE 从零到成熟< / title >
< meta name = "description" content = "SLI / SLO / 错误预算 模块目录:共 13 章、47 个小节。" >
< link rel = "stylesheet" href = "../../assets/doc.css" >
< / head >
< body >
< header class = "topbar" >
< div class = "tb-in" >
< a class = "brand" href = "../../index.html" > < span class = "logo" > SRE< / span > < div > 从零到成熟< small > 模块详解< / small > < / div > < / a >
< div class = "crumbs" >
< a href = "../../index.html" > 学习路径< / a > < span class = "sep" > /< / span >
< a href = "../../index.html#s3" > 阶段 3 · 稳得住< / a > < span class = "sep" > /< / span >
< b > SLI / SLO / 错误预算< / b >
< / div >
< div class = "spacer" > < / div >
< button class = "btn" id = "tocToggle" > ☰ 导航< / button >
< button class = "btn" id = "themeBtn" title = "切换到深色主题" > 深色< / button >
< / div >
< / header >
< div class = "layout" id = "layout" >
< aside class = "sidebar" >
< h2 > 章节目录< / h2 >
< nav id = "chapters" > < a class = "toc-a" href = "01-why.html" > < i class = "cn" > 1< / i > 为什么「稳定」必须先变成数字< / a > < div class = "subnav" > < a class = "toc-a lv3" href = "01-why.html#sec-1-1" > 没有 SLO 时,组织会退化成的三种行为< / a > < a class = "toc-a lv3" href = "01-why.html#sec-1-2" > SLO 到底改变了什么:从「尽力而为」到「有预算的冒险」< / a > < a class = "toc-a lv3" href = "01-why.html#sec-1-3" > 错误预算带来的三个具体变化< / a > < / div > < a class = "toc-a" href = "02-sli.html" > < i class = "cn" > 2< / i > 选 SLI: 必须站在用户视角< / a > < div class = "subnav" > < a class = "toc-a lv3" href = "02-sli.html#sec-2-1" > 四类标配 SLI 与它们的判定条件< / a > < a class = "toc-a lv3" href = "02-sli.html#sec-2-2" > 用户视角 vs 机器视角:同一个故障的两种叙述< / a > < a class = "toc-a lv3" href = "02-sli.html#sec-2-3" > 几条可执行的选取原则< / a > < / div > < a class = "toc-a" href = "03-slo.html" > < i class = "cn" > 3< / i > 定 SLO: 和业务谈目标值< / a > < div class = "subnav" > < a class = "toc-a lv3" href = "03-slo.html#sec-3-1" > 目标值 → 允许的坏时间:把百分比翻译成人话< / a > < a class = "toc-a lv3" href = "03-slo.html#sec-3-2" > 周期怎么定:滚动 28 天 vs 自然月< / a > < a class = "toc-a lv3" href = "03-slo.html#sec-3-3" > 内外部 SLO、目标分层与依赖预算< / a > < / div > < a class = "toc-a" href = "04-slimath.html" > < i class = "cn" > 4< / i > SLI 的计算实现:好事件 / 总事件< / a > < div class = "subnav" > < a class = "toc-a lv3" href = "04-slimath.html#sec-4-1" > 实现一:请求型可用性(非 5xx 比例)< / a > < a class = "toc-a lv3" href = "04-slimath.html#sec-4-2" > 实现二: 延迟型( histogram_quantile 之外的正确姿势)< / a > < a class = "toc-a lv3" href = "04-slimath.html#sec-4-3" > 实现三: 数据新鲜度( time() 减去上游时间戳)< / a > < a class = "toc-a lv3" href = "04-slimath.html#sec-4-4" > 为什么必须是「好事件数 / 总事件数」,而不是平均可用率< / a > < a class = "toc-a lv3" href = "04-slimath.html#sec-4-5" > 天滚动窗口与自然月窗口的实际差别< / a > < / div > < a class = "toc-a" href = "05-budget.html" > < i class = "cn" > 5< / i > 错误预算:把可靠性变成可花的钱< / a > < div class = "subnav" > < a class = "toc-a lv3" href = "05-budget.html#sec-5-1" > 定义与三个换算公式< / a > < a class = "toc-a lv3" href = "05-budget.html#sec-5-2" > PromQL: 本周期还剩多少预算< / a > < a class = "toc-a lv3" href = "05-budget.html#sec-5-3" > 燃尽图怎么读:三种形状对应三种结论< / a > < / div > < a class = "toc-a" href = "06-burnrate.html" > < i class = "cn" > 6< / i > 燃烧率告警:多窗口多燃烧率的算法< / a > < div class = "subnav" > < a class = "toc-a lv3" href = "06-burnrate.html#sec-6-1" > 燃烧率的定义与三个公式< / a > < a class = "toc-a lv3" href = "06-burnrate.html#sec-6-2" > 四档阈值的完整数学推导< / a > < a class = "toc-a lv3" href = "06-burnrate.html#sec-6-3" > 为什么必须长短窗口配对:解决「短窗口抖动」与「长窗口迟钝」< / a > < a class = "toc-a lv3" href = "06-burnrate.html#sec-6-4" > 可直接落地的完整规则文件< / a > < / div > < a class = "toc-a" href = "07-policy.html" > < i class = "cn" > 7< / i > 预算政策:耗尽时停什么、做什么、谁决定< / a > < div class = "subnav" > < a class = "toc-a lv3" href = "07-policy.html#sec-7-1" > 政策必须回答的五个问题< / a > < a class = "toc-a lv3" href = "07-policy.html#sec-7-2" > 分级动作:四档触发条件与对应行为< / a > < a class = "toc-a lv3" href = "07-policy.html#sec-7-3" > 可靠性欠债:把冻结期的时间用在对的地方< / a > < a class = "toc-a lv3" href = "07-policy.html#sec-7-4" > 可签署的政策模板< / a > < / div > < a class = "toc-a" href = "08-gate.html" > < i class = "cn" > 8< / i > 与发布门禁联动:把 SLO 接进 CI/CD< / a > < div class = "subnav" > < a class = "toc-a lv3" href = "08-gate.html#sec-8-1" > 门禁的三个卡点< / a > < a class = "toc-a lv3" href = "08-gate.html#sec-8-2" > 发布前门禁脚本(可直接用)< / a > < a class = "toc-a lv3" href = "08-gate.html#sec-8-3" > 流水线片段:门禁 + 金丝雀 + 观察期自动回滚< / a > < a class = "toc-a lv3" href = "08-gate.html#sec-8-4" > 与团队目标的关系: SLO 不是又一个 KPI< / a > < / div > < a class = "toc-a" href = "09-report.html" > < i class = "cn" > 9< / i > SLO 报表与周
< div class = "side-foot" >
< a class = "btn" href = "index.html" > ← 模块目录< / a >
< a class = "btn" href = "../../index.html" > 学习路径< / a >
< / div >
< / aside >
< div class = "mask" id = "mask" > < / div >
< main class = "main-col" >
< article >
< div class = "modhero" >
< span class = "mh-no" > 阶段 3 · 模块 1 / 4< / span >
< h1 > SLI / SLO / 错误预算< / h1 >
< p class = "mh-sub" > 阶段 3 · 可靠性与 SLO · 用户视角的指标、燃尽率告警、预算政策与发布门禁< / p >
< div class = "mh-meta" >
< span > 共 < b > 13< / b > 章< / span >
< span > < b > 47< / b > 个小节< / span >
< span > 约 < b > 59< / b > 千字< / span >
< / div >
< / div >
< p class = "lead" >
< b > 模块定位:< / b > 阶段 2 让你「看得见」,但看得见不等于说得清。当产品经理问「我们这个月到底稳不稳」,如果你只能回答一堆 CPU 和 QPS 曲线,那就还没有可度量的可靠性。这个模块把「稳定」从形容词变成数字:用 SLI 描述用户真正经历的服务质量,用 SLO 把数字变成承诺,用错误预算把承诺变成可以花、可以冻结发布的资源。学完这一模块,你和业务方开会时会带着一条趋势图和一份政策文档,而不是带着一句「感觉还行」。
< br > < br >
< b > 学完之后你应该能:< / b > 为任意一个核心接口选出 1– 4 个用户视角的 SLI 并用 PromQL 落地;和业务方谈出一个有依据的 SLO 目标值与统计窗口;写出多窗口多燃烧率的 recording rules 与 alerting rules, 做到「1 小时烧掉 2% 预算就报警」;写出一份能被签字执行的预算政策(触发条件、动作、决策人、恢复条件);把错误预算余量接进 CI/CD, 发布前判断该全量、该灰度还是该阻断, 发布后观察窗口内自动回滚; 每周产出一份能让团队据此做决定的 SLO 周报。
< br > < br >
< b > 前置:< / b > 阶段 2 的 < a href = "../s2-01-metrics/index.html" > 指标与 Prometheus< / a > (必须已经熟练使用 < code > rate()< / code > 、< code > histogram_quantile()< / code > 、recording rules) 与 < a href = "../s2-04-dashboard/index.html" > 看板与可视化< / a > (需要会画时间序列与燃尽图);阶段 1 的 < a href = "../s1-04-cicd/index.html" > CI/CD 流水线< / a > (第 8 章的门禁要挂在流水线上)。如果还没有一个能稳定抓取的 Prometheus 与至少一个真实在跑的 HTTP 服务,先补阶段 2 再回来。
< br > < br >
< b > 建议投入:< / b > 18– 22 小时,其中至少 8 小时要在真实环境里动手:写 PromQL、配告警规则、压一次故障看告警是否按预期触发、把门禁挂到流水线上。
< / p >
< h2 id = "chapters-list" > 章节目录< / h2 >
< ol class = "chaplist" >
< li class = "chap-item" >
< div class = "ci-head" >
< span class = "ci-no" > 1< / span >
< a class = "ci-title" href = "01-why.html" > 为什么「稳定」必须先变成数字< / a >
< a class = "ci-go" href = "01-why.html" > 进入 →< / a >
< / div >
< div class = "ci-secs" > < a href = "01-why.html#sec-1-1" > 没有 SLO 时,组织会退化成的三种行为< / a > < a href = "01-why.html#sec-1-2" > SLO 到底改变了什么:从「尽力而为」到「有预算的冒险」< / a > < a href = "01-why.html#sec-1-3" > 错误预算带来的三个具体变化< / a > < / div >
< / li >
< li class = "chap-item" >
< div class = "ci-head" >
< span class = "ci-no" > 2< / span >
< a class = "ci-title" href = "02-sli.html" > 选 SLI: 必须站在用户视角< / a >
< a class = "ci-go" href = "02-sli.html" > 进入 →< / a >
< / div >
< div class = "ci-secs" > < a href = "02-sli.html#sec-2-1" > 四类标配 SLI 与它们的判定条件< / a > < a href = "02-sli.html#sec-2-2" > 用户视角 vs 机器视角:同一个故障的两种叙述< / a > < a href = "02-sli.html#sec-2-3" > 几条可执行的选取原则< / a > < / div >
< / li >
< li class = "chap-item" >
< div class = "ci-head" >
< span class = "ci-no" > 3< / span >
< a class = "ci-title" href = "03-slo.html" > 定 SLO: 和业务谈目标值< / a >
< a class = "ci-go" href = "03-slo.html" > 进入 →< / a >
< / div >
< div class = "ci-secs" > < a href = "03-slo.html#sec-3-1" > 目标值 → 允许的坏时间:把百分比翻译成人话< / a > < a href = "03-slo.html#sec-3-2" > 周期怎么定:滚动 28 天 vs 自然月< / a > < a href = "03-slo.html#sec-3-3" > 内外部 SLO、目标分层与依赖预算< / a > < / div >
< / li >
< li class = "chap-item" >
< div class = "ci-head" >
< span class = "ci-no" > 4< / span >
< a class = "ci-title" href = "04-slimath.html" > SLI 的计算实现:好事件 / 总事件< / a >
< a class = "ci-go" href = "04-slimath.html" > 进入 →< / a >
< / div >
< div class = "ci-secs" > < a href = "04-slimath.html#sec-4-1" > 实现一:请求型可用性(非 5xx 比例)< / a > < a href = "04-slimath.html#sec-4-2" > 实现二: 延迟型( histogram_quantile 之外的正确姿势)< / a > < a href = "04-slimath.html#sec-4-3" > 实现三: 数据新鲜度( time() 减去上游时间戳)< / a > < a href = "04-slimath.html#sec-4-4" > 为什么必须是「好事件数 / 总事件数」,而不是平均可用率< / a > < a href = "04-slimath.html#sec-4-5" > 天滚动窗口与自然月窗口的实际差别< / a > < / div >
< / li >
< li class = "chap-item" >
< div class = "ci-head" >
< span class = "ci-no" > 5< / span >
< a class = "ci-title" href = "05-budget.html" > 错误预算:把可靠性变成可花的钱< / a >
< a class = "ci-go" href = "05-budget.html" > 进入 →< / a >
< / div >
< div class = "ci-secs" > < a href = "05-budget.html#sec-5-1" > 定义与三个换算公式< / a > < a href = "05-budget.html#sec-5-2" > PromQL: 本周期还剩多少预算< / a > < a href = "05-budget.html#sec-5-3" > 燃尽图怎么读:三种形状对应三种结论< / a > < / div >
< / li >
< li class = "chap-item" >
< div class = "ci-head" >
< span class = "ci-no" > 6< / span >
< a class = "ci-title" href = "06-burnrate.html" > 燃烧率告警:多窗口多燃烧率的算法< / a >
< a class = "ci-go" href = "06-burnrate.html" > 进入 →< / a >
< / div >
< div class = "ci-secs" > < a href = "06-burnrate.html#sec-6-1" > 燃烧率的定义与三个公式< / a > < a href = "06-burnrate.html#sec-6-2" > 四档阈值的完整数学推导< / a > < a href = "06-burnrate.html#sec-6-3" > 为什么必须长短窗口配对:解决「短窗口抖动」与「长窗口迟钝」< / a > < a href = "06-burnrate.html#sec-6-4" > 可直接落地的完整规则文件< / a > < / div >
< / li >
< li class = "chap-item" >
< div class = "ci-head" >
< span class = "ci-no" > 7< / span >
< a class = "ci-title" href = "07-policy.html" > 预算政策:耗尽时停什么、做什么、谁决定< / a >
< a class = "ci-go" href = "07-policy.html" > 进入 →< / a >
< / div >
< div class = "ci-secs" > < a href = "07-policy.html#sec-7-1" > 政策必须回答的五个问题< / a > < a href = "07-policy.html#sec-7-2" > 分级动作:四档触发条件与对应行为< / a > < a href = "07-policy.html#sec-7-3" > 可靠性欠债:把冻结期的时间用在对的地方< / a > < a href = "07-policy.html#sec-7-4" > 可签署的政策模板< / a > < / div >
< / li >
< li class = "chap-item" >
< div class = "ci-head" >
< span class = "ci-no" > 8< / span >
< a class = "ci-title" href = "08-gate.html" > 与发布门禁联动:把 SLO 接进 CI/CD< / a >
< a class = "ci-go" href = "08-gate.html" > 进入 →< / a >
< / div >
< div class = "ci-secs" > < a href = "08-gate.html#sec-8-1" > 门禁的三个卡点< / a > < a href = "08-gate.html#sec-8-2" > 发布前门禁脚本(可直接用)< / a > < a href = "08-gate.html#sec-8-3" > 流水线片段:门禁 + 金丝雀 + 观察期自动回滚< / a > < a href = "08-gate.html#sec-8-4" > 与团队目标的关系: SLO 不是又一个 KPI< / a > < / div >
< / li >
< li class = "chap-item" >
< div class = "ci-head" >
< span class = "ci-no" > 9< / span >
< a class = "ci-title" href = "09-report.html" > SLO 报表与周报< / a >
< a class = "ci-go" href = "09-report.html" > 进入 →< / a >
< / div >
< div class = "ci-secs" > < a href = "09-report.html#sec-9-1" > 周报的六块内容(附取值口径)< / a > < a href = "09-report.html#sec-9-2" > 一份真实的周报正文(模板 + 实例)< / a > < a href = "09-report.html#sec-9-3" > 自动生成:把周报变成一条 cron< / a > < / div >
< / li >
< li class = "chap-item" >
< div class = "ci-head" >
< span class = "ci-no" > 10< / span >
< a class = "ci-title" href = "10-antipattern.html" > 反模式: 100% 目标与两张皮< / a >
< a class = "ci-go" href = "10-antipattern.html" > 进入 →< / a >
< / div >
< div class = "ci-secs" > < a href = "10-antipattern.html#sec-10-1" > 反模式一:定 100% 目标< / a > < a href = "10-antipattern.html#sec-10-2" > 反模式二: SLO 与实际告警两张皮< / a > < a href = "10-antipattern.html#sec-10-3" > 反模式三:指标漂亮,用户仍在骂< / a > < / div >
< / li >
< li class = "chap-item" >
< div class = "ci-head" >
< span class = "ci-no" > 11< / span >
< a class = "ci-title" href = "11-lab.html" > 实操:为核心接口落地 SLI/SLO 与燃尽率告警< / a >
< a class = "ci-go" href = "11-lab.html" > 进入 →< / a >
< / div >
< div class = "ci-secs" > < a href = "11-lab.html#sec-11-1" > 实验环境与交付物清单< / a > < a href = "11-lab.html#sec-11-2" > 第 1– 2 步:定义 SLI 并验证数据可得性< / a > < a href = "11-lab.html#sec-11-3" > 第 3– 4 步:写规则文件并加载< / a > < a href = "11-lab.html#sec-11-4" > 第 5 步:燃尽图看板< / a > < a href = "11-lab.html#sec-11-5" > 第 6 步:预算政策定稿< / a > < a href = "11-lab.html#sec-11-6" > 第 7– 8 步:门禁与周报接线< / a > < a href = "11-lab.html#sec-11-7" > 验收演练:制造一次可控故障,走完整闭环< / a > < / div >
< / li >
< li class = "chap-item" >
< div class = "ci-head" >
< span class = "ci-no" > 12< / span >
< a class = "ci-title" href = "12-cheat.html" > 速查表与高频坑< / a >
< a class = "ci-go" href = "12-cheat.html" > 进入 →< / a >
< / div >
< div class = "ci-secs" > < a href = "12-cheat.html#sec-12-1" > 速查表< / a > < a href = "12-cheat.html#sec-12-2" > 十二个高频坑< / a > < a href = "12-cheat.html#sec-12-3" > 值班三分钟决策树< / a > < / div >
< / li >
< li class = "chap-item" >
< div class = "ci-head" >
< span class = "ci-no" > 13< / span >
< a class = "ci-title" href = "13-checklist.html" > 完成标准与自测< / a >
< a class = "ci-go" href = "13-checklist.html" > 进入 →< / a >
< / div >
< div class = "ci-secs" > < a href = "13-checklist.html#sec-x1" > 自测题< / a > < a href = "13-checklist.html#sec-x2" > 下一步< / a > < / div >
< / li >
< / ol >
< div class = "box tip" >
< span class = "bt" > 怎么用这一模块< / span >
< p > 左侧是< b > 章节目录树< / b > :先看章标题快速定位,进入某一章后该章的小节会展开并跟随滚动高亮;点其它章标题可直接跳到对应页面。< / p >
< p > 每章结尾都有「上一章 / 下一章」可以连续阅读,代码块右上角可以一键复制。< / p >
< / div >
< / article >
< nav class = "pager" >
< a class = "prev" href = "../s2-04-dashboard/index.html" > < span class = "k" > ← 上一模块< / span > < span class = "v" > 看板与可视化< / span > < / a >
< a class = "next" href = "../s3-02-ha/index.html" > < span class = "k" > 下一模块 →< / span > < span class = "v" > 高可用与容灾< / span > < / a >
< / nav >
< p class = "foot" >
SLI / SLO / 错误预算 · 模块目录< br >
< a href = "../../index.html" > 返回学习路径< / a >
< / p >
< / main >
< / div >
< button id = "toTop" title = "回到顶部" > ↑< / button >
< script src = "../../assets/doc.js" > < / script >
2026-10-14 22:42:38 +08:00
< script src = "../../../../assets/back.js" data-portal-back = "knowledge/sre-learning-path" data-portal-label = "知识库 › SRE 从零到成熟学习路径" > < / script >
2026-10-08 16:48:05 +08:00
< / body >
< / html >