diff --git a/monitoring/SLI-SLO.md b/monitoring/SLI-SLO.md new file mode 100644 index 0000000..46a5cfb --- /dev/null +++ b/monitoring/SLI-SLO.md @@ -0,0 +1,175 @@ +# Chapter 5 — SLI, SLO, and Error Budget + +## 1. Service Level Indicator (SLI) + +The availability SLI measures the fraction of successful HTTPS probes. + +SLI = Successful HTTPS probes / Total observed HTTPS probes + +A successful probe requires: +- HTTP 200 response. +- Valid TLS certificate. +- Completion within the configured probe timeout. + +Prometheus collects probe results every 30 seconds. + +The Gitea and Jenkins services are measured independently. + +## 2. Service Level Objective (SLO) + +The laboratory availability objective is: + +SLO >= 99% over a 24-hour observation window. + +At a 30-second sampling interval: + +24 hours * 60 minutes * 2 samples per minute = 2880 scheduled samples. + +The permitted failure fraction is: + +100% - 99% = 1%. + +Error budget: + +2880 * 0.01 = 28.8 failed samples. + +Because samples are discrete, the maximum number of failed samples +that still satisfies the SLO is 28. + +Equivalent scheduled failure time: + +28.8 * 30 seconds = 864 seconds = 14.4 minutes. + +The discrete sample limit is 28 * 30 = 840 seconds = 14 minutes. + +## 3. Mandatory Hypothetical Example + +The following values are hypothetical assignment examples, +not actual measurements from the deployed system. + +Gitea: +- Successful probes: 2880 +- Scheduled probes: 2880 +- Availability: 100% +- Result: PASS + +Jenkins: +- Successful probes: 2850 +- Scheduled probes: 2880 +- Failed probes: 30 +- Availability: 98.9583% +- Result: FAIL + +Jenkins exceeds the permitted error budget by: + +30 - 28.8 = 1.2 failed-sample equivalents. + +The Jenkins example therefore does not meet the 99% SLO. + +## 4. PromQL — Current Probe Status + +Gitea: + +probe_success{job="https",instance="https://git.sespinal590.dev/"} + +Jenkins: + +probe_success{job="https",instance="https://ci.165.227.90.215.sslip.io/login"} + +Interpretation: +- 1 = successful HTTPS probe. +- 0 = unsuccessful HTTPS probe. +- Missing series = no observation; do not automatically classify as success. + +## 5. PromQL — Observed Availability + +Gitea: + +avg_over_time(probe_success{job="https",instance="https://git.sespinal590.dev/"}[24h]) * 100 + +Jenkins: + +avg_over_time(probe_success{job="https",instance="https://ci.165.227.90.215.sslip.io/login"}[24h]) * 100 + +These queries calculate the percentage of successful observed samples. + +They do not prove that all 2880 scheduled samples were collected. + +## 6. PromQL — Observed Sample Counts + +Gitea: + +count_over_time(probe_success{job="https",instance="https://git.sespinal590.dev/"}[24h]) + +Jenkins: + +count_over_time(probe_success{job="https",instance="https://ci.165.227.90.215.sslip.io/login"}[24h]) + +Compare observed sample counts with the expected sampling schedule. + +A short observation window must be labeled as a short observation window. + +## 7. PromQL — Observed Failed Probes + +Gitea: + +count_over_time(probe_success{job="https",instance="https://git.sespinal590.dev/"}[24h]) +- +sum_over_time(probe_success{job="https",instance="https://git.sespinal590.dev/"}[24h]) + +Jenkins: + +count_over_time(probe_success{job="https",instance="https://ci.165.227.90.215.sslip.io/login"}[24h]) +- +sum_over_time(probe_success{job="https",instance="https://ci.165.227.90.215.sslip.io/login"}[24h]) + +These queries count observed failed probes. + +Missing samples require separate investigation. + +## 8. Controlled Outage Measurement + +During the planned Jenkins-only outage, record: + +- Exact UTC outage start time. +- Exact UTC outage end time. +- First failed HTTPS probe. +- Alert firing time. +- Notification receipt time. +- First successful recovery probe. +- Alert resolution time. + +Calculate the observed availability over the selected test window. + +Record the actual number of observed samples and failed samples. + +Do not substitute the hypothetical 24-hour example for real measurements. + +## 9. Jenkins Monitoring Access Requirement + +Jenkins currently uses a Caddy IP allowlist. + +An unapproved HTTPS request returns HTTP 403. + +The Jenkins backend /login endpoint was independently observed +returning HTTP 200 from inside the Caddy container. + +Before deployment, the team must arrange narrowly scoped monitoring +access that preserves the existing security restriction. + +HTTP 403 must not be counted as a successful Jenkins probe. + +## 10. Evidence Required Before Submission + +Capture evidence of: + +- Prometheus HTTPS probe targets. +- Actual probe_success results. +- Observed sample counts. +- Observed availability calculations. +- Jenkins controlled outage. +- Detection and recovery timestamps. +- SLO and error-budget interpretation. + +The hypothetical example must be clearly distinguished from +the actual deployment measurements. \ No newline at end of file