\chapter{Introduction to SRE: Monitoring and Reliability} \ChapterLabel{SREMonitoring} \index{monitoring}\index{incident review}\index{error budget} \section{Deployment and Reproducibility} \subsection{Scope, baseline, and decisions} Group 10 deployed four monitoring containers on October 30, 2026, using Turan Islamli's prepared branch and Sergio Espinal's authorized operational changes. This report records actual tests, rather than treating configuration as proof. The implementation remains on \path{chapter5-sre-monitoring}; main has not been merged. Human peer review remains outstanding. The Ubuntu 24.04 primary Droplet (165.227.90.215) originally had approximately 458 MiB RAM. An approved snapshot, ID 252241628, was retained before resizing CPU/RAM to 1 vCPU and 2 GB. The disk remains 10 GB as requested. Its root filesystem reports 8.7 GiB usable, approximately 7.0 GiB used and 1.8 GiB available (81\% used). Snapshot existence does not demonstrate a restore. The primary plan is \$12/month; the separate unchanged 512 MB Droplet costs \$4/month; the 5.65 GB snapshot is approximately \$0.34/month. Known total: approximately \$16.34/month before taxes or other usage. Sergio owns these resources and should remove the snapshot only after deciding it is no longer needed. No additional paid service was provisioned for monitoring. The full Grafana image and optional plugin downloads temporarily exhausted disk space during installation. Grafana was stopped, only the new full image and optional downloaded plugin files were removed, and the slim image was used. The Grafana database and all named volumes were preserved. The resulting image is approximately 1.23 GB rather than 2 GB. Only the Prometheus plugin 13.2.4 was installed; automatic plugin preinstallation and updates are disabled. The retained free-space margin is small and must be monitored. \subsection{Versions, storage, and actual topology} The deployed images are \path{prom/prometheus:v3.15.1}, \path{grafana/grafana:13.3.0-slim}, \path{quay.io/prometheus/node-exporter:v1.12.1}, and \path{quay.io/prometheus/blackbox-exporter:v0.29.1}. Publisher digests captured with \texttt{docker image inspect} are recorded below. Versions are pinned in Compose; the digests identify the images actually inspected. \begin{figure}[htbp]\centering\small \fbox{\begin{minipage}{0.94\linewidth}\centering \textbf{Primary Droplet: Ubuntu 24.04, 1 CPU, 2 GB RAM, 10 GB disk}\\[5pt] Browser $\xrightarrow{\mathrm{HTTPS}\ 443}$ \fbox{Caddy}\\ \path{gitea_default} proxy network: Caddy routes by hostname\\[4pt] \fbox{Gitea :3000}\quad \fbox{Jenkins :8080}\quad \fbox{Grafana :3000}\\[5pt] \textbf{Four separate monitoring containers}\\ \fbox{Grafana} $\xrightarrow{\mathrm{query}}$ \fbox{Prometheus :9090}\\[4pt] Prometheus $\xrightarrow{\mathrm{scrape\ every\ }30s}$ \fbox{Node Exporter :9100}\quad host /proc, /sys, /\\[4pt] Prometheus $\xrightarrow{\mathrm{probe\ request}}$ \fbox{Blackbox Exporter :9115}\\ Blackbox $\xrightarrow{\mathrm{TLS}\ 443}$ Caddy $\rightarrow$ Gitea /user/login and Jenkins /login\\[4pt] \path{monitoring_monitoring_private}: all four monitoring services\\ Grafana and Blackbox additionally join \path{gitea_default}.\\ Grafana $\xrightarrow{\mathrm{outbound\ HTTPS}}$ Discord team alerts\\[4pt] \textbf{Persistent storage:} Prometheus named volume $\rightarrow$ /prometheus;\\ Grafana named volume $\rightarrow$ /var/lib/grafana;\\ existing Gitea /data and Jenkins /var/jenkins\_home retained.\\ Configuration bind mounts originate in /opt/ssw590-monitoring.\\ Existing applications remain in /opt/gitea and /opt/jenkins.\\[4pt] \textbf{CI outside this diagram's metrics:} Windows LaTeX runner polls Gitea;\\ Jenkins application build executes on the primary controller. \end{minipage}} \caption{Actual deployment, October 30, 2026. Internal ports are not public listeners. Grafana is shown twice to clarify its query role, not as two containers.} \label{Figure:SRETopology}\end{figure} Prometheus retains up to seven days or 512 MB of stored blocks, whichever limit applies first. WAL/head storage is additional, so this is not a hard filesystem quota \cite{PrometheusStorage}. Grafana stores its SQLite database and installed plugin in its named volume. Removing volumes would destroy this persistence. All four containers use \texttt{unless-stopped} restart policies. \subsection{Repeatable operations} Check out the feature branch and copy the non-secret \path{monitoring/} directory to \path{/opt/ssw590-monitoring}. Privately supply the admin password, Grafana root URL, and the current Caddy private IP in a mode-600 \texttt{.env}. The proxy network must already exist. Confirm its subnet and that 172.18.0.250 is unused before assigning Blackbox's fixed address. Set readable configuration directories to 755 and non-secret files to 644. Keep the local Discord provisioning file owned by UID 472, group 0, mode 600. \begin{lstlisting}[basicstyle=\ttfamily\scriptsize,breaklines=true] cd /opt/ssw590-monitoring docker compose config --quiet docker compose up -d docker compose exec grafana grafana cli plugins install prometheus 13.2.4 docker compose restart grafana docker compose ps docker exec monitoring-prometheus-1 promtool check config /etc/prometheus/prometheus.yml \end{lstlisting} The commands were executed successfully during deployment. For updates, review image/plugin compatibility and available disk first, retain a backup, validate configuration, and recreate only the affected service. Do not run \texttt{down -v}. Recovery starts with \texttt{docker compose up -d}, target health and logs; restore known-good configuration before escalating to a backup restore. Reinstall the pinned plugin if rebuilding the Grafana volume. \subsection{Inspected publisher digests} \begin{lstlisting}[basicstyle=\ttfamily\tiny,breaklines=true] prom/prometheus@sha256:fa3302279710be2f21a8301ec17a8b4f2301fd829bd113839b3b6b02b6f191a2 grafana/grafana@sha256:a66f098dd9b2e1b5a19287ff176db02d895122488c6e39b3dfcd3fb897039225 quay.io/prometheus/node-exporter@sha256:1b4e4438faca4dd7e001dd445d161a4a2091b0fededa84093b3a8dfeae1f1be0 quay.io/prometheus/blackbox-exporter@sha256:ea1c7aa3ef3f307cd03e85f34abb604478ccb90b567fc690da0cd9776da76b13 \end{lstlisting} \section{Metrics and Probes} Prometheus privately scrapes itself, Node Exporter and Blackbox Exporter, plus two relabeled HTTPS probe targets every 30 seconds. Five \texttt{up} series were 1 at the verification checkpoint; both \path{probe_success} values were 1 after recovery. A successful scrape (\texttt{up}) means collection worked; it does not establish that the application probe succeeded. Node Exporter has read-only host-root and proc/sys access. Its \path{node_memory_MemTotal_bytes} was 2,063,564,800 bytes, consistent with host \texttt{free}. The root series labels were verified as \path{device=/dev/vda1}, \path{mountpoint=/}, \texttt{fstype=ext4}, matching \texttt{df}. This excludes container overlay filesystems. The HTTPS module requires HTTP 200, valid certificate verification and a response before its timeout. Targets are the actual TLS login URLs below. The exporter resolves both hostnames to Caddy's private 172.18.0.3 address, retaining their hostname/SNI and TLS verification. This measures the private proxy/application route; it cannot establish public DNS or external Internet availability. A shared-host outage also stops its own monitoring. \section{HTTPS and Access Control} \begin{itemize} \item Gitea login: \url{https://git.sespinal590.dev/user/login}. \item Jenkins login: \url{https://ci.165.227.90.215.sslip.io/login}. \item Grafana: \url{https://metrics.165.227.90.215.sslip.io}. \end{itemize} Use the team account for Gitea, the existing administrator's approved Jenkins access path, and the privately held Grafana admin password. Anonymous Grafana access and self-registration are disabled; its cookie is secure. No grader account is required to read the embedded evidence. Caddy provides HTTPS and forwards the metrics hostname to \texttt{grafana:3000}. The existing Jenkins IP restriction was retained with only Blackbox's 172.18.0.250/32 added. A public 403 from an unapproved source is expected access denial and is not treated as successful availability. The exporter obtained 200 from Jenkins through the narrow permitted route. Caddy's configuration was backed up before modification. \begin{lstlisting}[basicstyle=\ttfamily\scriptsize,breaklines=true] # Existing Jenkins allowlist plus the one monitoring address: remote_ip 155.246.151.38/32 172.18.0.1/32 172.18.0.250/32 # Additional HTTPS virtual host: metrics.165.227.90.215.sslip.io { reverse_proxy grafana:3000 } \end{lstlisting} No monitoring service has Compose host-port mappings. External TCP checks from Sergio's Windows workstation on October 30 could not connect to primary ports 3000, 8080, 9090, 9100 or 9115. HTTPS remained reachable. These are point-in-time observations from that source, not a universal firewall guarantee. \begin{tabularx}{\linewidth}{L{3cm}Y} \caption{Chapter 5 hosts, storage and credential hints\label{Table:SREHosts}}\\ \toprule Service / owner & Address, exposure, storage or secret handling\\\midrule Primary / Sergio & 165.227.90.215; Caddy HTTPS 443; SSH for approved operators. Snapshot retained; monitoring runs here.\\ Grafana / Sergio & metrics hostname above; private 3000; named Grafana volume. Admin secret stays in root-owned server .env; never in Git or PDF.\\ Prometheus / Sergio & Private prometheus:9090; named metrics volume; no user-facing login.\\ Exporters / Sergio & Private node-exporter:9100 and blackbox-exporter:9115; read-only configuration/host mounts.\\ Discord / team & Dedicated Discord integration; secret destination in \texttt{discord.local.yml} on server only. Rotate via Discord if exposed.\\ \bottomrule\end{tabularx} These entries supplement the existing Hosts and Password Hints tables in \ChapterRef{Gitea}; no credentials are reproduced. \section{Dashboard and CI Correlation} The provisioned dashboard is \textit{Chapter 5 -- SRE Monitoring Overview}, UID \texttt{sre-overview}, UTC, default one hour, refresh 30 seconds. Its versioned source is \path{monitoring/grafana/dashboards/sre-overview.json}. The six panels use the following expressions (each line is one panel's query). \begin{lstlisting}[basicstyle=\ttfamily\scriptsize,breaklines=true] 100 * (1 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle",job="node-exporter"}[5m]))) node_memory_MemAvailable_bytes{job="node-exporter"} 100 * node_filesystem_avail_bytes{job="node-exporter",mountpoint="/",fstype!~"tmpfs|overlay"} / node_filesystem_size_bytes{job="node-exporter",mountpoint="/",fstype!~"tmpfs|overlay"} probe_success{job="https",instance="https://git.sespinal590.dev/user/login"} probe_success{job="https",instance="https://ci.165.227.90.215.sslip.io/login"} probe_duration_seconds{job="https"} \end{lstlisting} CPU is the non-idle fraction averaged over CPUs, percent; available RAM is bytes rendered in GiB/MiB; root availability is percent for the one verified root mount; service lines are binary 0/1; durations are seconds with separate Gitea/Jenkins legends. Availability is not an HTTP request error rate for all users. Whole-host CPU cannot be attributed solely to Jenkins. \begin{figure}[p]\centering \includegraphics[width=\linewidth,height=0.82\textheight,keepaspectratio]{evidence/chapter5/dashboard-live.png} \caption{Actual Grafana six-panel dashboard, October 30, 2026, UTC. The Jenkins-only outage is visible while Gitea stays at 1.} \label{Figure:SREDashboard}\end{figure} After recovery, Jenkins \path{startup-product-ci/main} build 3 passed for commit \path{6cfac4ec1e6d56dbb0b1a66bd59775b9db6ed065}. It ran from 20:43:32.534 to 20:43:52.340 UTC (19.806 seconds), on the Jenkins controller. See \url{https://ci.165.227.90.215.sslip.io/job/startup-product-ci/job/main/3/}. The host measurements immediately before, during and after this build were: \begin{center}\begin{tabular}{lrr}\toprule UTC evaluation & CPU (one-minute rate) & Available RAM (MiB)\\\midrule 20:43:00 (before) & 41.57\% & 878.0\\ 20:43:45 (during) & 17.40\% & 863.8\\ 20:44:30 (after) & 17.67\% & 914.5\\\bottomrule \end{tabular}\end{center} The short build's CPU peak is not established by these snapshots. They include Jenkins initialization, monitoring and other work; the 30-second scrape cadence and one-minute rate smooth the 19.8-second build. The dashboard uses five-minute CPU smoothing. Available RAM fell slightly during the build and rose afterward, which is correlation rather than proof of per-container allocation. The Windows LaTeX workflow executes off-droplet, so its build load is not measured by these host metrics. \section{SLI, SLO, and Error Budget} An \gls{sli} is a measured indicator; here it is successful HTTPS observations divided by received observations for a named service and window. The \gls{slo} is an internal target of at least 99\% success over 24 hours. An \gls{sla} is a customer agreement that may attach consequences; this lab establishes no customer SLA. \subsection{Required hypothetical example} These figures are illustrative, not measured lab results. At 30 seconds, 24 hours schedules $24\times60\times2=2880$ probes per service. Gitea's $2880/2880=100\%$ meets the target. Jenkins's $2850/2880\times100=98.9583\%$ misses it, with 30 failures. The theoretical budget is $0.01\times2880=28.8$ failures or $28.8\times30/60=14.4$ minutes. At most 28 whole failed samples meet 99\%. Thirty failures exceed the budget by 1.2 samples, approximately 0.6 minutes. \subsection{Measured short exercise window} The actual interval is (20:35:00,20:45:00] UTC on October 30, evaluated at 20:45:00 with a 30-second scrape interval. Queries were \path{avg_over_time}, \path{count_over_time} and \path{sum_over_time} of \texttt{probe\_success\{job="https"\}[10m]}. Multiply the average by 100 for percent. \begin{center}\begin{tabular}{lrrrr}\toprule Service & Received / expected & Successes & Failures & Percent\\\midrule Gitea & 20 / 20 & 20 & 0 & 100\%\\ Jenkins & 20 / 20 & 13 & 7 & 65\%\\\bottomrule \end{tabular}\end{center} Both have 100\% sample coverage in this short window. The services have different scrape phases, so timestamps differ; no samples were missing in this interval. Seven failed Jenkins samples correspond to approximately 3.5 minutes under uniform sampling. Actual endpoints transitioned between scrapes, so sample counts do not provide continuous-time precision. Missing observations in another window would be unknown, not successes. This exercise does not establish whether the full 24-hour SLO was met. \section{Alerts and Runbooks} Both Grafana-managed rules have owner \texttt{sespinal}, a 30-second evaluation interval, summaries and links to \path{monitoring/ALERTING-RUNBOOK.md}. Service unavailability uses \texttt{probe\_success\{job="https"\}<1}, pending one minute, severity critical, retaining instance labels. Disk uses the same verified root percentage as the dashboard, below 15\% for five minutes, severity warning. Fifteen percent provides a response margin on this small disk. No-data state is \texttt{NoData}; evaluation errors are \texttt{Error}, rather than healthy. Grafana creates separate data-source alerts for these conditions \cite{GrafanaNoData}. The service expression additionally uses a zero-valued fallback from the matching target \texttt{up} series when its probe series disappears: \texttt{or on(instance,job) (0 * up\{job="https"\})}. Thus a failed collection does not silently become a successful probe. Removing a target from configuration still requires source review; it is not an availability fix. \begin{figure}[htbp]\centering \includegraphics[width=\linewidth]{evidence/chapter5/alerts-recovered.png} \caption{Actual Grafana group showing both provisioned rules normal after the tests, October 30, 2026. The rule-state JSON records retain firing transitions.} \label{Figure:SREAlerts}\end{figure} Both route through the dedicated Discord integration in contact point \texttt{team-alerts}. Policy groups by folder and alert name, waits 10 seconds, uses a 30-second group interval and four-hour repeat interval. Resolved messages are enabled. The webhook is stored only in server-local provisioning. The contact test succeeded, and Sergio confirmed its receipt, then confirmed receipt of both real firing and both resolved notifications. Exact Discord receipt/acknowledgement timestamps were not retained; do not substitute Grafana evaluation times for receiver times. For HTTPS failures, inspect the instance, \texttt{up}, Blackbox diagnostics, TLS, Caddy and application state. Keep TLS verification and the Jenkins allowlist intact; restart only the affected service and verify probe recovery and CI. For disk, inspect \texttt{df}, Docker images and volume/log growth; remove only verified disposable material after review. Preserve application and monitoring volumes. Recheck the filesystem and resolved state. The disk test changed only its threshold from 15 to 30\% at 20:37:26.770 UTC. It reached firing by observation 20:42:57.308, after five minutes pending. The script's \texttt{finally} block restored 15\% at 20:43:27.486; it was inactive by 20:43:57.520. No disk-filling workload was used. \section{Incident and Recovery} \subsection{Controlled Jenkins incident and measurements} The exercise stopped only Jenkins, retaining all volumes and the recovery command. A 210-second systemd safety timer was installed before stopping it; the primary script restarted it after approximately three minutes. Gitea, Caddy and the four monitoring containers remained available during the outage. All times below are October 30, 2026 UTC. \begin{tabularx}{\linewidth}{L{3.6cm}Y} \caption{Observed incident timeline\label{Table:SRETimeline}}\\ \toprule Time & Event and evidence\\\midrule 20:38:45.484 & Jenkins stop requested; stopped at 20:38:46.995.\\ 20:39:09.110 & First recorded failed Jenkins probe; previous success 20:38:39.110.\\ 20:40:30 evaluation & HTTPS alert firing, observed by polling at 20:40:57.\\ 20:41:47.511 & Restart requested; container started 20:41:47.945.\\ 20:42:09.110 & Probe still failed while Jenkins initialized.\\ 20:42:39.110 & First successful post-outage probe.\\ 20:43:27.344 or earlier & Rule observed inactive; subsequent evaluations stayed normal.\\ 20:43:32.534--52.340 & Recovery pipeline build 3 SUCCESS.\\ \bottomrule\end{tabularx} Stop request to first failed sample was 23.626 seconds. First failure to the 20:40:30 firing evaluation was 80.890 seconds, consistent with scrape phase, 30-second evaluation and one-minute pending. Stop request to first recovered sample was 233.626 seconds; restart request to that sample was 51.599 seconds. Seven failed probes bound the observed failure period. Discord firing and resolved receipt were confirmed by Sergio, but precise delivery/acknowledgement latencies cannot be calculated from the retained record. \subsection{Persistence and integration checks} Prometheus and Grafana were restarted separately without volume deletion. A historical instant query at 20:40:00 returned Jenkins 0 and Gitea 1 both before and after the Prometheus restart. Grafana's health returned database OK; dashboard UID \texttt{sre-overview}, both rules (1m/5m) and the Discord contact point remained. Collection can pause during restarts; the complete 10-minute SLI window above predates them. This test demonstrates persistence, not backup restoration. Raw sanitized records are under \path{evidence/chapter5/}. Gitea Actions manual-pdf run 16 (displayed build 12), source \path{2fc6e8909034bd615fd5f3caffd71f0ef386d18f}, passed in 44 seconds before final documentation changes: \url{https://git.sespinal590.dev/group10-startup/devops-it-manual/actions/runs/16}. The final automated artifact carries build \WorkflowRunNumber{} and source \href{https://git.sespinal590.dev/group10-startup/devops-it-manual/commit/\SourceRevision}{\SourceRevision{}} in its generated metadata. Its workflow record is available from \href{https://git.sespinal590.dev/group10-startup/devops-it-manual/actions}{the repository Actions page}. Human approval of this source revision is still required. Chapter 4's test/build failure is different: code can fail a pipeline while Jenkins remains available. Here the CI server itself was unavailable, so jobs could not execute during that interval. Retained Chapter 4 records link \href{https://ci.165.227.90.215.sslip.io/job/startup-product-ci/job/PR-9/1/}{failed PR-9 build 1} (commit \path{35605c33b903742cd13d444a1a14d61b07fbaa86}) and \href{https://ci.165.227.90.215.sslip.io/job/startup-product-ci/job/PR-9/2/}{repaired build 2} (commit \path{ed8684a2897c407946320183e572f6412dbb7703}, SUCCESS). Those historical records do not establish current peer-review status. The recovery build published a fresh success status to Gitea at 20:43:52 UTC, context \path{startup-product-ci/pipeline/head}, target build 3, matching commit \path{6cfac4ec1e6d56dbb0b1a66bd59775b9db6ed065}. The repository has no configured webhook; the retained polling fallback is distinct from webhook delivery. This manual run verifies execution and status publication, not an automatic new-commit trigger. \subsection{Blameless review and owned improvements} The intended maintenance injection caused the incident. Jenkins initialization extended user-visible unavailability beyond the stopped-container interval. Detection worked; Gitea remained successful throughout the measured window; Jenkins recovered and a normal build passed. No person is blamed for the capacity issue: the original disk budget was too small for the default image and optional plugins, and the slim deployment restored a workable margin. The current setup shares the failure domain it monitors. It also relies on Caddy's dynamic private IP, and precise receiver acknowledgement timestamps were not captured. The following owned issues track improvements: \begin{itemize} \item \href{https://git.sespinal590.dev/group10-startup/devops-it-manual/issues/2}{Issue 2}, P1, Sergio (\texttt{sespinal}): add an independent external TLS availability check; verify notification and recovery without exposing private ports. \item \href{https://git.sespinal590.dev/group10-startup/devops-it-manual/issues/3}{Issue 3}, P2, Turan (\texttt{turanisl}): remove fragile proxy-address dependence and verify coordinated rebuilds, private access, TLS and rollback. \end{itemize} \section{Manual Integration and Traceability} Source and prepared configuration are retained on the feature branch. The workflow indentation and master include typo were repaired first. The final PDF includes the source revision from workflow build metadata. Use that revision to inspect the exact source, rather than relying only on a moving branch link. The updated history, service/secret-hints table, glossary, references and AI log accompany this chapter. \paragraph{Review boundary.} Deployment, rule evaluation, notification receipt, controlled recovery and persistence have measured evidence. Human peer review and main merge remain outstanding; main merge is explicitly deferred by Sergio. Receiver timestamps, automatic new-commit trigger validation, and precise restart collection-gap measurement remain limitations. A successful PDF build does not close those gaps.