Files
nageshwaran_manikumar 98bc4f135d
startup-product-gitea-ci/pipeline/head This commit looks good
startup-product-gitea-ci/pipeline/pr-main This commit looks good
docs: restore SRE chapter and integrate secure delivery chapter 6
2026-11-13 22:43:43 -05:00

78 lines
11 KiB
TeX

\chapter{Introduction to SRE: Monitoring and Reliability}
\label{chap:sre}
\section{Purpose, Scope, and Deployment}
This chapter documents operational monitoring for the team's existing DigitalOcean Ubuntu 24.04 Droplet, Gitea source control, and Jenkins CI service. The monitoring stack uses Docker Compose with Prometheus v3.5.0, Grafana OSS v12.1.1, Blackbox Exporter v0.27.0, and Node Exporter v1.9.1. Caddy exposes Grafana over HTTPS at \url{https://monitor.nageshwaran.dev}. Exporter and Prometheus endpoints are addressed internally on the monitoring Docker network rather than deliberately exposed as public service ports. Persistent Docker storage is configured for monitoring services. The deployment was designed for a resource-constrained Droplet (approximately 512 MB RAM, 1 GB swap, and 10 GB nominal disk).
\section{Architecture and Monitoring Pipeline}
\begin{center}\small
\fbox{\begin{minipage}{0.91\linewidth}\centering
Gitea HTTPS / Jenkins HTTPS $\longrightarrow$ Blackbox Exporter\\[5pt]
Droplet CPU / RAM / filesystem $\longrightarrow$ Node Exporter\\[5pt]
Exporters $\longrightarrow$ Prometheus (30-second scrape)\\[5pt]
Prometheus $\longrightarrow$ Grafana dashboards and alert evaluation\\[5pt]
Grafana Alertmanager $\longrightarrow$ Discord contact point
\end{minipage}}
\end{center}
The monitored service URLs are \url{https://git.nageshwaran.dev} and \url{https://ci.nageshwaran.dev/login}. The blackbox HTTP module performs HTTPS checks, follows redirects, and validates successful responses. Prometheus uses the \texttt{https-probes} job, plus \texttt{node-exporter} and \texttt{prometheus} scrape jobs. The evaluation interval is 30 seconds.
\section{Grafana Dashboard and Metrics Evidence}
The \emph{SSW590 - SRE Monitoring Dashboard} contains six time-series panels: CPU usage, available RAM, available root filesystem percentage, Jenkins HTTPS availability, Gitea HTTPS availability, and combined HTTPS response time. The screenshots below show a six-hour window with recorded metrics rather than empty placeholder panels.
\begin{figure}[H]\centering\includegraphics[width=\linewidth]{img/grafana_https_availability_latency.png}\caption{HTTPS response-time series and Jenkins availability. Brief Jenkins availability drops reflect controlled incident testing.}\label{fig:sre-latency}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=\linewidth]{img/grafana_gitea_disk.png}\caption{Gitea HTTPS availability and root filesystem free-space percentage, approximately 18\% during the test.}\label{fig:sre-disk}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=\linewidth]{img/grafana_ram_cpu.png}\caption{Available RAM in bytes and Droplet CPU utilization percentage.}\label{fig:sre-host}\end{figure}
\begin{lstlisting}[caption={Representative Prometheus queries used by the dashboard}]
probe_success{job="https-probes"}
probe_duration_seconds{job="https-probes"}
node_memory_MemAvailable_bytes
100 * (1 - avg(rate(node_cpu_seconds_total{mode="idle"}[5m])))
100 * node_filesystem_avail_bytes{mountpoint="/",fstype!~"tmpfs|overlay"}
/ node_filesystem_size_bytes{mountpoint="/",fstype!~"tmpfs|overlay"}
\end{lstlisting}
\section{Service Level Indicators, Objectives, and Error Budget}
The service level indicator (SLI) is the fraction of successful HTTPS probes, independently calculated for Jenkins and Gitea. The proposed service level objective (SLO) is at least 99.9\% successful probes over a rolling 30-day period. The corresponding downtime budget is $30\times24\times60\times(1-0.999)=43.2$ minutes per 30 days. This is a \emph{target}, not a claim that 30 days of observations have been collected.
\begin{lstlisting}[caption={Rolling one-hour availability percentage per service}]
100 * avg_over_time(probe_success{job="https-probes"}[1h])
\end{lstlisting}
The captured instantaneous results of this rolling-window query showed 100\% for Jenkins and 100\% for Gitea. The historical graph also shows Jenkins' one-hour rolling SLI temporarily falling to approximately 91\% during earlier outage testing before returning to 100\%; Gitea stayed at 100\% in the captured view. A 100\% latest one-hour result does not establish compliance over 30 days. An hour with 99.9\% SLO has a theoretical downtime allowance of 3.6 seconds; a controlled multi-minute outage exceeds that hour's proportional budget. Probe-based SLI approximates availability at the scrape interval and is not exact user-request uptime.
\begin{figure}[H]\centering\includegraphics[width=\linewidth]{img/sli_slo_availability.png}\caption{Prometheus rolling one-hour HTTPS availability SLI query and two observed 100\% results, with earlier Jenkins degradation visible in the history.}\label{fig:sre-sli}\end{figure}
\section{Alert Rules and Discord Notification Routing}
Two Grafana-managed rules are grouped under \texttt{SSW590 - SRE Monitoring / SSW590-SRE-Alerts}, evaluated every 30 seconds. Both route to the \texttt{SSW590 Discord Alerts} contact point. The HTTPS service-down rule evaluates \texttt{probe\_success} and fires after a sustained failure of at least one minute. The disk rule evaluates available root filesystem percentage and fires if it stays below 15\% for five minutes. Both have zero keep-firing duration. Discord contact-point delivery was independently verified during the incident exercises.
\begin{center}\small\begin{tabularx}{\linewidth}{@{}L{3.0cm}Y L{2cm}L{2cm}@{}}\toprule Rule & Condition & Pending & Recovery delay\\\midrule
HTTPS Service Down & HTTPS probe failure for Jenkins or Gitea & 1 minute & 0 seconds\\
Low Disk Space & Root filesystem available $<15\%$ & 5 minutes & 0 seconds\\\bottomrule\end{tabularx}\end{center}
\section{Controlled Jenkins Outage and Recovery}
A controlled Jenkins outage was conducted by stopping the Jenkins container, while the monitoring stack and Gitea remained operational. Blackbox Exporter detected the HTTPS probe failure; Grafana transitioned the HTTPS service alert through Pending and Firing, and a Discord \textbf{FIRING} message was delivered. Jenkins was restarted with \texttt{docker start jenkins}; the container was subsequently running, and a local request to \texttt{/login} returned HTTP 200. Grafana then returned to Normal and Discord delivered a \textbf{RESOLVED} message. The Jenkins dashboard plot shows probe drops, while Gitea continued responding. This verifies detection and recovery signaling, not automatic self-healing. A post-recovery Jenkins pipeline run was also verified: the job checked out the configured Gitea branch, passed the JavaScript syntax check and both automated tests, reported zero failures, and ended with \texttt{Finished: SUCCESS}. No Jenkins build was executed during the outage, so outage-time build behavior is not claimed.
\section{Safe Disk Alert Simulation}
The actual root filesystem had approximately 18\% available capacity. To test alerting without consuming scarce disk space, the rule's threshold was temporarily raised from 15\% to 25\%, leaving the five-minute pending period unchanged. The rule became Pending, then Firing. Discord received the \textbf{FIRING} notification at approximately 10:59 PM on October 30, 2026, reporting about 17.98\% free space on \texttt{/dev/vda1}. The threshold was restored to the required 15\%; Discord subsequently delivered a \textbf{RESOLVED} notification at 11:19 PM, with the annotation \texttt{grafana\_state\_reason = Updated}. The recovery was therefore a controlled rule-configuration reset, not a claim that disk usage had been reduced. No large test files were written.
\section{Operations, Risk, and Follow-Up}
Operators should inspect Grafana alerts and Prometheus targets, check \texttt{docker ps}, examine container logs and Caddy routing, and verify service health after recovery. For low disk capacity, inspect \texttt{df -h} and \texttt{docker system df} before considering safe cleanup; do not blindly delete volumes, application data, or audit evidence. The small Droplet has limited headroom, and Grafana/Prometheus retention and resource usage require attention. Rotate the Discord webhook if it has been disclosed outside its intended secret store.
\section{Evidence Coverage and Outstanding Validation}
\begin{center}\small\begin{tabularx}{\linewidth}{@{}Y L{2.5cm}@{}}\toprule Requirement & Evidence status\\\midrule
Dashboard: CPU, RAM, disk, uptime, latency & Verified (Figures \ref{fig:sre-latency}--\ref{fig:sre-host})\\
HTTPS alert with Discord firing and resolved & Verified in incident account\\
Disk alert with Discord firing and resolved & Verified in notification text\\
One-hour SLI and proposed 99.9\% SLO & Verified / calculated\\
Grafana/Prometheus restart and historical data & Verified (restart and dashboard screenshots)\\
Jenkins post-recovery CI build & Verified (successful build; outage-time build not tested)\\
Two reliability-improvement Gitea issues & Verified (issues \#10 and \#11)\\\bottomrule\end{tabularx}\end{center}
The Discord screenshots are included below. The monitoring restart test was performed by restarting Grafana and Prometheus individually; both containers returned to the running state, the dashboard remained accessible, and historical time-series data remained visible. Docker volumes \texttt{monitoring\_grafana\_data} and \texttt{monitoring\_prometheus\_data} were present. This is a practical restart/persistence check, not a full Droplet reboot test. Jenkins build evidence is post-recovery only; no build was run during the outage.
\section{Additional Operational Verification Evidence}
The following captured evidence supplements the dashboard and SLI figures above. It records the Discord delivery of both alert transitions, the restart/persistence check, the successful post-recovery CI build, and the two follow-up reliability issues.
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_19.png}\caption{Discord: HTTPS service-down alert in FIRING state.}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_20.png}\caption{Discord: HTTPS service-down alert RESOLVED after Jenkins recovery.}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_21.png}\caption{Discord: low-disk-space alert FIRING during the safe threshold simulation.}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_22.png}\caption{Discord: low-disk-space alert RESOLVED after restoring the 15\% threshold. The notification reports the state reason as Updated.}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_17.png}\caption{Monitoring stack restart and container status verification.}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_18.png}\caption{Grafana dashboard after the monitoring restart, with historical metrics still visible.}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_13.png}\caption{Jenkins post-recovery pipeline execution evidence.}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_15.png}\caption{Jenkins post-recovery build details and successful completion.}\end{figure}
\begin{figure}[H]\centering\includegraphics[width=0.96\linewidth]{img/sre_evidence/evidence_16.png}\caption{Gitea reliability follow-up issues, including issue numbers 10 and 11.}\end{figure}