diff --git a/manual/latex/abstract.tex b/manual/latex/abstract.tex index e45e431..116fcfb 100644 --- a/manual/latex/abstract.tex +++ b/manual/latex/abstract.tex @@ -5,8 +5,9 @@ run as four pinned containers beside Gitea and Jenkins on the 1\,GiB DigitalOcean droplet, with Grafana at \url{https://metrics.yebilly.me/login} for approved networks only. A dashboard shows host CPU, memory, and disk and the HTTPS availability of Gitea and Jenkins. A 99\% availability objective is -defined and measured, and two alert rules notify the team's Discord channel. -Both rules were shown firing and resolving, the second through a planned -Jenkins outage that was detected in about two minutes and recovered about a -minute after restart. Earlier chapters retain the group's prior assignment +defined and measured, and three alert rules (service availability, disk +space, and collection health) notify the team's Discord channel. Each was +shown firing and resolving; the availability rule through a planned Jenkins +outage that was detected in about two minutes and recovered about a minute +after restart. Earlier chapters retain the group's prior assignment results, including the Jenkins merge gate and the Gitea Actions manual build. diff --git a/manual/latex/devopsAIPromptLog.tex b/manual/latex/devopsAIPromptLog.tex index 649e15f..ab13cec 100644 --- a/manual/latex/devopsAIPromptLog.tex +++ b/manual/latex/devopsAIPromptLog.tex @@ -719,8 +719,19 @@ authentication, so Billy pushed and re-authorized Git Credential Manager. Billy's questions about the CPU readings led to the I/O-wait finding and the dashboard change. -Outputs used: commits \texttt{d3a5e6b} and \texttt{b6cf080} and the chapter -commit on \texttt{feature/issue-19-monitoring}; +Review and corrections: at Billy's request, Claude had an independent +subagent audit the chapter against the instructor's requirements. Claude +checked its findings against the evidence (two of its ``unsupported'' +claims were supported by earlier output and a figure) and, with Billy's +approval, added a collection-health rule and tested it by stopping Blackbox +Exporter, ran Blackbox Exporter as non-root, compared CPU counters with +\texttt{/proc/stat}, and corrected four figures and the overstated +no-data claim. Billy replaced the Grafana administrator password himself; +Claude confirmed the old value was rejected and removed it from the +secrets file without printing it. + +Outputs used: commits \texttt{d3a5e6b} and \texttt{b6cf080}, the chapter +commits on \texttt{feature/issue-19-monitoring} (PR \#22); \texttt{monitoring/EVIDENCE.md}; \ChapterRef{SREMonitoring}; this record. Assumptions and unresolved items: the title-page assignment title comes from the Canvas page Billy showed (``\#7 Grafana and Promethous SRE -- diff --git a/manual/latex/devopsAssignment.tex b/manual/latex/devopsAssignment.tex index 6d7e2d7..f772b97 100644 --- a/manual/latex/devopsAssignment.tex +++ b/manual/latex/devopsAssignment.tex @@ -151,8 +151,8 @@ \include{devopsHostsPasswords} % Restore when a chapter cites devopsReferences.bib. -%\bibliographystyle{IEEEtran} -%\bibliography{devopsReferences} +\bibliographystyle{IEEEtran} +\bibliography{devopsReferences} \appendix \include{devopsDocumentGuide} diff --git a/manual/latex/devopsDocumentHistory.tex b/manual/latex/devopsDocumentHistory.tex index 4f00726..467fc31 100644 --- a/manual/latex/devopsDocumentHistory.tex +++ b/manual/latex/devopsDocumentHistory.tex @@ -12,7 +12,7 @@ link each entry to the changed chapter, table, figure, or controlled artifact. \multicolumn{4}{l}{\small\itshape Document Update History (continued)}\\ \toprule \textbf{Date / Version} & \textbf{Author Initials} & \textbf{Change} & \textbf{Changed At}\\ \midrule \endhead \bottomrule \endlastfoot -October 28, 2026 / 5.0 & BY, CD & Assignment 7: added \ChapterRef{SREMonitoring}. Deployed Prometheus, Grafana OSS, Node Exporter, and Blackbox Exporter on The-Ocean (pinned by digest, memory-capped, no host ports) after a capacity trial on the 1\,GiB plan; disabled four unused host services and added a second swap file; added \texttt{metrics.yebilly.me} behind the Jenkins allowlist and a private probe network. Recorded the dashboard, normal-build comparison, SLI/SLO worked example and measured window, contact-point, capacity-alert and Jenkins-outage tests with Discord notifications, restart persistence, blameless review, and improvement issues \#20 and \#21. \textbf{Updated the Hosts table} (monitoring containers, ports, volumes, \texttt{metrics} DNS, swap, monitoring and backup status) and \textbf{the Passwords table} (Grafana administrator, monitoring secrets file, Discord webhook). Set the Assignment 7 title page and abstract; added glossary terms. & Title and abstract, \ChapterRef{SREMonitoring}, \ChapterRef{HostsPasswords}, \ChapterRef{AIPromptLog}\\ +October 28, 2026 / 5.0 & BY, CD & Assignment 7: added \ChapterRef{SREMonitoring}. Deployed Prometheus, Grafana OSS, Node Exporter, and Blackbox Exporter on The-Ocean (pinned by digest, memory-capped, no host ports) after a capacity trial on the 1\,GiB plan; disabled four unused host services and added a second swap file; added \texttt{metrics.yebilly.me} behind the Jenkins allowlist and a private probe network. Recorded the dashboard, normal-build comparison, SLI/SLO worked example and measured window, contact-point, capacity-alert, collection-health, and Jenkins-outage tests with Discord notifications, restart persistence, blameless review, and improvement issues \#20 and \#21. After an independent review of the draft: added the collection-health rule and its test, replaced the initial Grafana administrator password, ran Blackbox Exporter as non-root, and added runbooks, network and storage detail in the diagram, host CPU checks, a targets table, citations with a Bibliography, and four corrected figures. \textbf{Updated the Hosts table} (monitoring containers, ports, volumes, \texttt{metrics} DNS, swap, monitoring and backup status) and \textbf{the Passwords table} (Grafana accounts, monitoring secrets file, Discord webhook). Set the Assignment 7 title page and abstract; added glossary terms. & Title and abstract, \ChapterRef{SREMonitoring}, \ChapterRef{HostsPasswords}, \ChapterRef{AIPromptLog}\\ October 23, 2026 / 4.2 & VS, CDX & Corrected the Jenkins lockfile link to the recorded 63-plugin revision; clarified clean reproduction, Jenkins revision selection, and the unconfirmed webhook-timeout cause. Scoped the existing update-check result to the 63 checked plugins. Theme plugins are unchanged at Vincent's direction. Hosts and Passwords tables are unchanged because no service, account, or credential changed. & \ChapterRef{JenkinsCI}, \ChapterRef{AIPromptLog}\\ October 23, 2026 / 4.1 & BY, CD & Corrected the Jenkins instructor access path to the Stevens campus network, with off-campus graders' addresses added on request; recorded the GlobalProtect test showing the Stevens VPN is split-tunnel and therefore not an access path, and Vincent's passing campus test on \texttt{Stevens-Net}; added the real webhook delivery table and diagnosis of one timed-out delivery, UML stereotypes on the deployment diagram, the stored Jenkins URL, free disk space, reconciled plugin counts, and corrected wording on push rights, resource limits, and corrective actions. Shortened AI initials in this table (CDX for Codex, CD for Claude). Hosts and Passwords tables are unchanged. & \ChapterRef{JenkinsCI}, \ChapterRef{AIPromptLog}\\ October 22--23, 2026 / 4.0 & BY, VS, CD & Assignment 6: ran the guarded Jenkins capacity test on the resized 1\,GiB droplet; deployed Jenkins 2.580.1 LTS with a hashed plugin lockfile behind Caddy at \texttt{ci.yebilly.me} (Stevens and team allowlist); integrated Gitea via a private webhook and the \texttt{jenkins-bot} identity; required check \texttt{vpn-dns-gateway/pipeline/pr-main} on \texttt{main}; recorded PR~\#15's pass, blocked failure, repair, review, and merge, the restart-persistence and IPv4/IPv6 exposure tests, and the plugin-update check. \textbf{Updated the Hosts table} (resize, Jenkins, \texttt{ci} DNS, Color Buttons retired) and \textbf{the Passwords table} (Jenkins administrators, \texttt{jenkins-bot} account and token, CI allowlist file). Added glossary terms, set the Assignment 6 title page and abstract, and noted the completed Assignment 5 merge. & Title and abstract, \ChapterRef{JenkinsCI}, \ChapterRef{HostsPasswords}, \ChapterRef{AutomatedManualBuild}, \ChapterRef{AIPromptLog}\\ diff --git a/manual/latex/devopsHostsPasswords.tex b/manual/latex/devopsHostsPasswords.tex index e97dd31..e4515d2 100644 --- a/manual/latex/devopsHostsPasswords.tex +++ b/manual/latex/devopsHostsPasswords.tex @@ -49,7 +49,7 @@ no host ports; SQLite file in volume \texttt{gitea\_gitea-data}; Jenkins state in volume \texttt{gitea\_jenkins-home}. Monitoring (Compose project \texttt{monitoring}, no host ports): Prometheus \texttt{:9090} (128\,MiB), Node Exporter \texttt{:9100} and Blackbox Exporter \texttt{:9115} (32\,MiB -each) on network \texttt{monitoring\_monitoring}; Grafana \texttt{:3000} +each; Blackbox runs as \texttt{nobody}) on network \texttt{monitoring\_monitoring}; Grafana \texttt{:3000} (192\,MiB) also on \texttt{gitea\_web}; Blackbox at \texttt{172.30.90.10} on \texttt{gitea\_probe} (172.30.90.0/28); volumes \texttt{monitoring\_prometheus\_data} (7\,d / 500\,MB) and @@ -69,7 +69,7 @@ Gitea (\ChapterRef{GiteaFoundation}), restart persistence for Jenkins \texttt{monitoring/README.md}\\ Monitoring status & Prometheus and Grafana: host CPU, memory, root disk, and HTTPS probes of Gitea and Jenkins every 30\,s; alerts \emph{HTTPS service -down} and \emph{Root disk space low} to Discord \texttt{\#devops-alerts}. +down}, \emph{Root disk space low}, and \emph{Monitoring target down} to Discord \texttt{\#devops-alerts}. Shares the droplet's failure domain; no external check yet (issue~\#20)\\ \end{tabularx} \normalsize @@ -111,9 +111,9 @@ Gitea \texttt{jenkins-bot} (added 22 Oct 2026) & BY & BY's password manager; use Jenkins \texttt{billy} & BY & BY's password manager & Administer (all)\\ Jenkins \texttt{vsun1} & VS & VS's password manager & Administer (all)\\ Jenkins initial admin password & --- & One-time setup secret in \texttt{/var/jenkins\_home/secrets/}; read once by BY, superseded by named accounts & Setup only\\ -Grafana \texttt{billy} (added 28 Oct 2026) & BY & BY's password manager; initial value in the monitoring secrets file, used only when Grafana first created its database & Grafana Admin\\ +Grafana \texttt{billy} (added 28 Oct 2026) & BY & BY's password manager; the initial value set through the monitoring secrets file was replaced in Grafana on 28 Oct 2026 and removed from the file & Grafana Admin\\ Grafana \texttt{vsun1} (added 28 Oct 2026) & VS & VS's password manager; temporary password set by BY and sent privately, to be changed by VS at first login & Viewer\\ -Monitoring secrets \texttt{.env.secret} & BY & \texttt{\textasciitilde/monitoring/.env.secret} on the droplet, mode 600, root; typed by BY; holds the initial Grafana admin password and the Discord webhook URL; never in Git & n/a\\ +Monitoring secrets \texttt{.env.secret} & BY & \texttt{\textasciitilde/monitoring/.env.secret} on the droplet, mode 600, root; typed by BY; holds the Discord webhook URL (the initial Grafana admin password was removed after it was replaced); never in Git & n/a\\ Discord webhook \texttt{Grafana} & BY & BY's password manager and the monitoring secrets file; revoke under \texttt{\#devops-alerts} $\rightarrow$ Integrations $\rightarrow$ Webhooks & Post to \texttt{\#devops-alerts}\\ CI allowlist \texttt{.env} & BY & \texttt{\textasciitilde/gitea/.env} on the droplet, root-only; holds team and approved grader IP addresses (personal data, not a secret); grader entries are removed after grading & n/a\\ DigitalOcean team & BY, VS & Each member's own login, in their password manager & Team member\\ diff --git a/manual/latex/devopsReferences.bib b/manual/latex/devopsReferences.bib index 59f00cb..0f9b4a8 100644 --- a/manual/latex/devopsReferences.bib +++ b/manual/latex/devopsReferences.bib @@ -4,3 +4,46 @@ publisher = {IT Revolution Press}, year = {2018} } + +@book{SREWorkbook, + author = {Beyer, Betsy and Murphy, Niall Richard and Rensin, David K. and Kawahara, Kent and Thorne, Stephen}, + title = {The Site Reliability Workbook: Practical Ways to Implement {SRE}}, + publisher = {O'Reilly Media}, + year = {2018}, + note = {Chapter 2, ``Implementing SLOs,'' \url{https://sre.google/workbook/implementing-slos/}, accessed Oct. 28, 2026} +} + +@misc{PrometheusDocs, + author = {{Prometheus Authors}}, + title = {Prometheus Documentation: Configuration, Storage, and Querying}, + howpublished = {\url{https://prometheus.io/docs/prometheus/latest/}}, + note = {Version 3.15; accessed Oct. 28, 2026} +} + +@misc{NodeExporter, + author = {{Prometheus Authors}}, + title = {Node Exporter}, + howpublished = {\url{https://github.com/prometheus/node_exporter}}, + note = {Release v1.12.1; accessed Oct. 28, 2026} +} + +@misc{BlackboxExporter, + author = {{Prometheus Authors}}, + title = {Blackbox Exporter}, + howpublished = {\url{https://github.com/prometheus/blackbox_exporter}}, + note = {Release v0.29.1; accessed Oct. 28, 2026} +} + +@misc{GrafanaDocker, + author = {{Grafana Labs}}, + title = {Run {Grafana} {Docker} Image}, + howpublished = {\url{https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/}}, + note = {Grafana OSS 13.2; accessed Oct. 28, 2026} +} + +@misc{GrafanaAlerting, + author = {{Grafana Labs}}, + title = {Grafana Alerting: Provision Alerting Resources and Configure Contact Points}, + howpublished = {\url{https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/file-provisioning/}}, + note = {Grafana OSS 13.2; accessed Oct. 28, 2026} +} diff --git a/manual/latex/devopsSRE.tex b/manual/latex/devopsSRE.tex index 0aa35ad..760fec2 100644 --- a/manual/latex/devopsSRE.tex +++ b/manual/latex/devopsSRE.tex @@ -24,15 +24,20 @@ Vincent is the verifier and pull-request reviewer. Times are UTC unless marked Eastern (EDT, UTC$-$4). Sections~\ref{Section:SREDeployment}--\ref{Section:SREQuality} follow the eight rubric rows in order. Raw timestamps for every test are kept in -\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/commit/b6cf08061815acd628bf3caaa90e38c46d57a8e7/monitoring/EVIDENCE.md}{\texttt{monitoring/EVIDENCE.md}}. +\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring/EVIDENCE.md}{\texttt{monitoring/EVIDENCE.md}}; +repository links in this chapter point to \texttt{main}, where +\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/pulls/22}{PR~\#22} +merges this work. \begin{devopsNote}[Result summary] The stack fits on the existing 1\,GiB droplet without a resize, with memory -caps and a second swap file. Both HTTPS probes, both alert rules, and the -Discord route were tested for real: a disk-space rule fired and resolved -under a temporarily raised threshold, and a planned 4~min~48~s Jenkins stop -fired the availability alert about 2~minutes after injection and resolved -about 1.5~minutes after the restart. Gitea stayed available throughout. The +caps and a second swap file. Both HTTPS probes, all three alert rules, and +the Discord route were tested for real: a disk-space rule fired and resolved +under a temporarily raised threshold; a planned 4~min~48~s Jenkins stop fired +the availability alert about 2~minutes after injection and resolved about +1.5~minutes after the restart; and stopping Blackbox Exporter fired the +collection-health rule and the availability rule's no-data handling. Gitea +stayed available throughout. The main measured weakness is memory pressure: about 15\% of CPU time is spent waiting on swap (improvement \href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/issues/21}{issue~\#21}). @@ -44,9 +49,10 @@ waiting on swap (improvement \index{monitoring!deployment} \paragraph{Baseline and capacity decision.} -At 04:34 on October 28 the droplet ran Ubuntu 24.04.5 LTS on 1 vCPU with -961\,MiB RAM; 147--229\,MiB was available and 414\,MiB of the 1\,GiB swap -file was already in use. Jenkins used 325\,MiB, Gitea 98\,MiB, and Caddy +At 04:34 on October 28 the droplet ran Ubuntu 24.04.5 LTS (kernel +6.8.0-147, Docker Engine 29.8.1, Compose v5.5.1) on 1 vCPU with 961\,MiB RAM; +147--219\,MiB was available in two samples 17\,s apart, and 414\,MiB of the +1\,GiB swap file was already in use. Jenkins used 325\,MiB, Gitea 98\,MiB, and Caddy 11\,MiB; the root disk had 18.8\,GB of 24.9\,GB free. The four new containers were expected to need 150--240\,MiB, so the team chose a \emph{capped trial} on the existing plan instead of an immediate resize, with @@ -63,9 +69,9 @@ occurred. The trial therefore became the deployment. Section~\ref{Section:SREDas shows its cost: frequent swap-in wait. \paragraph{Versions and images.} -All four images come from the projects' own repositories and are pinned by +All four images come from the projects' own repositories~\cite{PrometheusDocs,GrafanaDocker,NodeExporter,BlackboxExporter} and are pinned by tag \emph{and} digest in -\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/commit/b6cf08061815acd628bf3caaa90e38c46d57a8e7/monitoring/compose.yaml}{\texttt{monitoring/compose.yaml}} +\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring/compose.yaml}{\texttt{monitoring/compose.yaml}} (Table~\ref{Table:SREImages}). The instructor suggests a \texttt{.env} file for the tags; this repository ignores every \texttt{.env} file to keep secrets out of Git, so the versions live in the Compose file instead and are @@ -87,7 +93,7 @@ Blackbox Exporter & \nolinkurl{quay.io/prometheus/blackbox-exporter:v0.29.1} & \ \end{table} \paragraph{Retention and storage.} -Prometheus keeps 7 days or 500\,MB, whichever limit is reached first +Prometheus keeps 7 days or 500\,MB, whichever limit is reached first~\cite{PrometheusDocs} (\texttt{--storage.tsdb.retention.time=7d}, \texttt{--storage.tsdb.retention.size=500MB}), and its Go runtime aims to stay under 96\,MiB (\texttt{GOMEMLIMIT}). With about 15\,GB free after the @@ -95,6 +101,19 @@ image pulls (Grafana's image alone is 1.95\,GB), this leaves room for the operating system, Gitea, and builds. Node Exporter runs only the CPU, memory, filesystem, load, and uname collectors. +\paragraph{Identities and mounts.} +Prometheus and Node Exporter run as \texttt{nobody} (UID 65534) and Grafana +as UID 472, the images' defaults. Blackbox Exporter's image runs as root; +because HTTP probes need no privileges, it was changed to +\texttt{user: "65534:65534"} on October 28 at 17:33 and probes kept working. +Prometheus stores its database at \texttt{/prometheus} (volume +\nolinkurl{monitoring_prometheus_data}) and Grafana its database and plugins +at \texttt{/var/lib/grafana} (volume \nolinkurl{monitoring_grafana_data}). +Configuration is bind-mounted read-only: +\texttt{/etc/prometheus/prometheus.yml}, \texttt{/config/blackbox.yml}, +\texttt{/etc/grafana/provisioning}, and \texttt{/var/lib/grafana-dashboards}; +Node Exporter reads the host at \texttt{/host} (read-only). + \paragraph{Deployment diagram.} Figure~\ref{Figure:SREDeployment} shows what was built. Prometheus and both exporters sit only on the private \texttt{monitoring} network. Grafana also @@ -115,15 +134,16 @@ address 172.30.90.10 and Caddy answers as \texttt{git.yebilly.me} and arr/.style={-{Stealth}, thick}] \node[box] (browser) at (-0.6,0) {\guillemotleft device\guillemotright\\Team / grader\\browser}; \node[box] (fw) at (3.4,0) {\guillemotleft device\guillemotright\\Cloud Firewall\\\texttt{gitea-fw}, 443 / 80}; - \node[box] (caddy) at (7.9,0) {\guillemotleft container\guillemotright\\Caddy TLS proxy\\allowlist: \texttt{ci}, \texttt{metrics}}; - \node[box] (gitea) at (13.4,2.4) {\guillemotleft container\guillemotright\\Gitea \texttt{:3000}}; - \node[box] (jenkins) at (13.4,0.6) {\guillemotleft container\guillemotright\\Jenkins \texttt{:8080}}; - \node[new] (grafana) at (13.4,-1.7) {\guillemotleft container\guillemotright\\Grafana OSS \texttt{:3000}\\dashboard, alert rules}; - \node[new] (prom) at (13.4,-4.7) {\guillemotleft container\guillemotright\\Prometheus \texttt{:9090}\\scrapes every 30\,s}; - \node[new] (bbox) at (7.9,-4.7) {\guillemotleft container\guillemotright\\Blackbox Exporter\\\texttt{:9115}, 172.30.90.10}; - \node[new] (node) at (17.8,-4.7) {\guillemotleft container\guillemotright\\Node Exporter\\\texttt{:9100}, host \texttt{/} (ro)}; + \node[box] (caddy) at (7.9,0) {\guillemotleft container\guillemotright\\Caddy TLS proxy\\allowlist: \texttt{ci}, \texttt{metrics}\\{\scriptsize net: \textit{web, probe}}}; + \node[box] (gitea) at (13.4,2.4) {\guillemotleft container\guillemotright\\Gitea \texttt{:3000}\\{\scriptsize net: \textit{web}}}; + \node[box] (jenkins) at (13.4,0.6) {\guillemotleft container\guillemotright\\Jenkins \texttt{:8080}\\{\scriptsize net: \textit{web}}}; + \node[new] (grafana) at (13.4,-1.7) {\guillemotleft container\guillemotright\\Grafana OSS \texttt{:3000}\\dashboard, alert rules\\{\scriptsize net: \textit{web, mon}}}; + \node[new] (prom) at (13.4,-4.7) {\guillemotleft container\guillemotright\\Prometheus \texttt{:9090}\\scrapes every 30\,s\\{\scriptsize net: \textit{mon}}}; + \node[new] (bbox) at (7.9,-4.7) {\guillemotleft container\guillemotright\\Blackbox Exporter\\\texttt{:9115}, 172.30.90.10\\{\scriptsize net: \textit{mon, probe}}}; + \node[new] (node) at (17.8,-4.7) {\guillemotleft container\guillemotright\\Node Exporter\\\texttt{:9100}, host \texttt{/} (ro)\\{\scriptsize net: \textit{mon}}}; \node[box] (pvol) at (13.4,-7.2) {\guillemotleft artifact\guillemotright\\\texttt{prometheus\_data}\\7\,d / 500\,MB}; \node[box] (gvol) at (17.8,-1.7) {\guillemotleft artifact\guillemotright\\\texttt{grafana\_data}\\users, alert state}; + \node[box] (evol) at (17.8,1.5) {\guillemotleft artifact\guillemotright\\\texttt{gitea-data}, \texttt{jenkins-home},\\\texttt{caddy-data}, \texttt{caddy-config}}; \node[box] (discord) at (3.4,-7.2) {\guillemotleft device\guillemotright\\Discord\\\texttt{\#devops-alerts}}; \draw[arr] (browser) -- node[lbl, above=3pt]{HTTPS} (fw); \draw[arr] (fw) -- (caddy); @@ -136,32 +156,37 @@ address 172.30.90.10 and Caddy answers as \texttt{git.yebilly.me} and \draw[arr, dashed, devopsGreen] (bbox.north) -- node[lbl, pos=0.78, left=2pt, align=right]{HTTPS probes\\(\texttt{gitea\_probe})} (caddy.south); \draw[arr] (prom) -- (pvol); \draw[arr] (grafana) -- (gvol); + \draw[arr] (gitea.east) -| ([xshift=-6mm]evol.north); + \draw[arr] (jenkins.east) -- (jenkins.east -| evol.west); \draw[arr, dashed, devopsRed] (grafana.230) -- ++(0,-0.95) -| node[lbl, pos=0.8, left=2pt]{alerts (HTTPS out)} (discord.north); - \node[draw, dashed, rounded corners, fit=(caddy) (gitea) (jenkins) (grafana) (prom) (bbox) (node) (pvol) (gvol), inner sep=10pt, + \node[draw, dashed, rounded corners, fit=(caddy) (gitea) (jenkins) (grafana) (prom) (bbox) (node) (pvol) (gvol) (evol), inner sep=10pt, label={[font=\scriptsize]above:\guillemotleft device\guillemotright\ Droplet \texttt{The-Ocean} (1\,GiB RAM, 2\,GiB swap) / \guillemotleft executionEnvironment\guillemotright\ Docker networks \texttt{gitea\_web}, \texttt{gitea\_probe}, \texttt{monitoring}}] {}; \end{tikzpicture}} \caption{UML deployment diagram after Assignment 7. Shaded boxes are the four new containers; arrows point from the side that opens the connection. Only Caddy's 80/443 are public. Blackbox Exporter probes the real HTTPS hostnames through Caddy on the private probe network; Grafana sends alert notifications -outward to Discord. Gitea's and Jenkins' volumes are as in -\ChapterRef{JenkinsCI}.} +outward to Discord. Network tags: \textit{web} = \texttt{gitea\_web}, +\textit{probe} = \texttt{gitea\_probe}, \textit{mon} = +\texttt{monitoring\_monitoring}. Artifacts are named Docker volumes (Compose +prefixes \texttt{gitea\_} and \texttt{monitoring\_} omitted); Caddy's volumes +hold its certificates and configuration.} \label{Figure:SREDeployment} \end{figure} \paragraph{Configuration in Git and secrets outside it.} The -\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/commit/b6cf08061815acd628bf3caaa90e38c46d57a8e7/monitoring}{\texttt{monitoring/}} +\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring}{\texttt{monitoring/}} folder holds the Compose file, \texttt{prometheus/prometheus.yml}, \texttt{blackbox/blackbox.yml}, Grafana provisioning (data source, dashboard -loader, both alert rules, the contact point), the dashboard JSON, and a +loader, three alert rules, the contact point), the dashboard JSON, and a \texttt{README.md} with deploy, update, backup, rollback, and runbook steps. Provisioned items are read-only in Grafana's interface, so Git is their source -of truth. Two secrets live only in \texttt{\textasciitilde/monitoring/.env.secret} -on the droplet (mode 600, root): the initial Grafana administrator password -and the Discord webhook URL. Billy typed both in his own SSH session; the -contact point reads the URL through \texttt{\$DISCORD\_WEBHOOK\_URL}, so -it appears in no file in Git. Monitoring containers get no Docker socket and +of truth. Secrets live only in \texttt{\textasciitilde/monitoring/.env.secret} +on the droplet (mode 600, root), typed by Billy in his own SSH session: the +Discord webhook URL, and until it was replaced (Section~\ref{Section:SREAccess}) +the initial Grafana administrator password. The contact point reads the URL +through \texttt{\$DISCORD\_WEBHOOK\_URL}, so it appears in no file in Git. Monitoring containers get no Docker socket and no \texttt{privileged} flag. Node Exporter needs the host's process ID namespace and a read-only bind of \texttt{/} to report host CPU, memory, and disk; that mount lets the container read host files, which is accepted for @@ -182,22 +207,32 @@ docker compose up -d && docker compose ps \end{minted} The \texttt{chmod} line was added after Grafana first logged \texttt{permission denied}: \texttt{scp} from Windows creates root-only -directories, and Grafana runs as user 472. Start-up order does not matter, -and every service uses \texttt{restart: unless-stopped}. Routine pauses use +directories, and Grafana runs as user 472. The Gitea stack in +\texttt{\textasciitilde/gitea} must be up first, because it creates the +external networks \texttt{gitea\_web} and \texttt{gitea\_probe}; inside the +monitoring stack the start-up order does not matter, and every service uses +\texttt{restart: unless-stopped}. Routine pauses use \texttt{docker compose stop}/\texttt{start}; \texttt{docker compose down -v} must never be used because it deletes both named volumes. An upgrade changes one image's tag and digest at a time after a backup, and is rolled back by restoring the backup rather than assuming an older release can read newer data. Grafana and Prometheus state that Git cannot rebuild (users, alert -state, metric history) is backed up with the \texttt{tar} procedure in the -README; no scheduled backup exists yet. +state, metric history) is backed up as follows; no scheduled backup exists +yet: +\begin{minted}[breaklines]{sh} +cd ~/monitoring && docker compose stop grafana prometheus +docker run --rm -v monitoring_grafana_data:/g:ro -v monitoring_prometheus_data:/p:ro \ + -v /root/backups:/b alpine tar czf /b/monitoring-$(date -u +%Y%m%dT%H%M%SZ).tgz /g /p +docker compose start grafana prometheus +\end{minted} \paragraph{Restart persistence.} Prometheus was restarted at 16:12:09 and answered at 16:12:15; its oldest sample (14:52:16) remained, and the raw scrapes at 16:12:06 and 16:12:36 show no missed interval because the restart fell between them. Grafana was -restarted at 16:12:56; at 16:13:44 the dashboard (version~2, 7 panels), the -data source, both rules, the contact point, and the administrator login were +restarted at 16:12:56; at 16:13:44 the dashboard (with the I/O-wait change, +7 panels), the data source, the two rules then defined, the contact point, and +the administrator login were all present. A restart shows persistence on the named volumes; it is not a backup restore. @@ -224,8 +259,44 @@ uses the multi-target pattern: each URL becomes the probe target and the - {source_labels: [__param_target], target_label: instance} - {target_label: __address__, replacement: blackbox-exporter:9115} \end{minted} -At about 14:56 all five targets reported \texttt{up} with no error; scrape -durations were 0.03--0.23\,s. +The target view used for collection health (Prometheus' targets API, which +the \emph{Scrape health} panel also shows) is summarized in +Table~\ref{Table:SRETargets}. + +\begin{table}[H] +\centering\footnotesize +\caption{Scrape targets, October 28, 2026 (UTC)\label{Table:SRETargets}} +\begin{tabular}{@{}llllr@{}} +\toprule \textbf{Job} & \textbf{Target (instance)} & \textbf{Health} & \textbf{Last error} & \textbf{Scrape time}\\ \midrule +\texttt{prometheus} & \texttt{prometheus:9090} & up & none & 0.022\,s\\ +\texttt{node} & \texttt{node-exporter:9100} & up & none & 0.062\,s\\ +\texttt{blackbox} & \texttt{blackbox-exporter:9115} & up & none & 0.004\,s\\ +\texttt{https} & \texttt{https://git.yebilly.me/user/login} & up & none & 0.128\,s\\ +\texttt{https} & \texttt{https://ci.yebilly.me/login} & up & none & 0.064\,s\\ +\bottomrule +\end{tabular} +\end{table} +\noindent All five were also up with no error at about 14:56, shortly after +start-up (scrape times 0.031--0.226\,s); the table shows the check at 17:31. + +\paragraph{Probe module.} +\texttt{blackbox/blackbox.yml} defines the module the \texttt{https} job uses~\cite{BlackboxExporter}: +\begin{minted}[breaklines]{yaml} +modules: + http_2xx: + prober: http + timeout: 10s + http: + method: GET + preferred_ip_protocol: ip4 + valid_status_codes: [] # empty = any 2xx + follow_redirects: true + fail_if_not_ssl: true + tls_config: + insecure_skip_verify: false +\end{minted} +The probes use IPv4: the private probe network has no IPv6, and public DNS +publishes only \texttt{A} records. \paragraph{Probe success criteria.} The \texttt{http\_2xx} module defines success as: a DNS answer, a TLS @@ -252,7 +323,7 @@ hair-pinned visitors with a network gateway address (first 172.18.0.1, now confirms it is. \paragraph{Host metric verification.} -At 14:56:37 Node Exporter's root filesystem series carried the labels +At 14:56:37 Node Exporter's~\cite{NodeExporter} root filesystem series carried the labels \texttt{device="/dev/vda1"}, \texttt{fstype="ext4"}, and \texttt{mountpoint="/"}; the container's overlay filesystems are excluded by Node Exporter's defaults. The dashboard and the disk alert select exactly @@ -260,7 +331,13 @@ Node Exporter's defaults. The dashboard and the disk alert select exactly 24{,}883{,}167{,}232\,bytes, equals \texttt{df -B1 /}; available bytes differed by 4\,KB from \texttt{df}, read seconds apart. \texttt{MemTotal} (1{,}008{,}177{,}152\,bytes) equals \texttt{free -b}; \texttt{MemAvailable} -was 293.4 against 301.0\,MB a few seconds apart. +was 293.4 against 301.0\,MB a few seconds apart. CPU counters were compared +with \texttt{/proc/stat} (divided by \texttt{USER\_HZ} = 100) at 17:30:59: +user 4{,}099.5 against 4{,}100.8\,s, system 1{,}768.0 against 1{,}768.9\,s, +idle 562{,}034 against 562{,}053\,s, I/O wait 2{,}078.2 against 2{,}080.2\,s, +steal 1{,}726.4 against 1{,}727.5\,s. Each exported counter trails the kernel +by about the age of the last scrape (up to 30\,s), so the panels derive CPU +use from rates rather than raw totals. \begin{table}[htbp] \centering\footnotesize @@ -291,10 +368,26 @@ Jenkins: \url{https://ci.yebilly.me/login}; Grafana: \url{https://metrics.yebilly.me/login}. Gitea is public. Jenkins and Grafana answer only the Stevens network 155.246.0.0/16 and approved team or grader addresses, then require their own -login. Grafana has no anonymous access and no self sign-up. Accounts: -\texttt{billy} (Admin) and \texttt{vsun1} (Vincent, Viewer, added at 17:03; -least privilege, because changes go through Git). Graders do not need an account: the dashboard and -alert evidence is in this chapter. +login. Grafana has no anonymous access and no self sign-up +(\texttt{GF\_AUTH\_ANONYMOUS\_ENABLED=false}, \texttt{GF\_USERS\_ALLOW\_SIGN\_UP=false}), +its session cookie is marked secure, and its external root URL is set to +\texttt{https://metrics.yebilly.me/} (\texttt{GF\_SERVER\_ROOT\_URL}) so +alert links and redirects use the HTTPS hostname. Accounts: \texttt{billy} +(Admin) and \texttt{vsun1} (Vincent, Viewer, added at 17:03; least privilege, +because changes go through Git). Graders do not need an account: the +dashboard and alert evidence is in this chapter. + +\paragraph{Initial credential.} +Grafana's built-in \texttt{admin}/\texttt{admin} was never active: the first +administrator, \texttt{billy}, was created at first start with a password +Billy typed into the root-only secrets file. That first password was then +replaced in Grafana (\emph{Profile} $\rightarrow$ \emph{Change password}) on +October 28; at 17:29:34 the old value was rejected (HTTP 401), its line was +deleted from \texttt{.env.secret}, and recreating Grafana at 17:33 removed it +from the container's environment. The current password exists only in +Billy's password manager and Grafana's database. The change came several +hours after first login rather than immediately, because the gap was found +in a review of this chapter. \paragraph{DNS and certificate.} Billy added the \texttt{A} record \texttt{metrics} $\rightarrow$ @@ -336,7 +429,18 @@ Caddyfile were copied to \texttt{\textasciitilde/gitea/backup-20261028T144040Z}. \pagebreak[3] \paragraph{External exposure tests.} Billy's laptop (home network on the team allowlist; IPv6 available) ran the -tests in Table~\ref{Table:SREExposure} at 14:57. +tests in Table~\ref{Table:SREExposure} at 14:57 with \texttt{curl}; a status +of \texttt{000} means no TCP connection within the 5\,s limit: +\begin{minted}[breaklines]{sh} +for host in 147.182.178.136 "[2604:a880:400:d1:0:5:22d:6001]"; do + for p in 3000 3001 8080 9090 9100 9115 50000; do + curl -s -o /dev/null -m 6 --connect-timeout 5 -w "%{http_code}" "http://$host:$p/"; echo " $host:$p" + done +done +curl -s -o /dev/null -w "%{http_code}" https://metrics.yebilly.me/api/dashboards/uid/group1-sre +curl -s -6 -o /dev/null --resolve ci.yebilly.me:443:2604:a880:400:d1:0:5:22d:6001 \ + -w "%{http_code}" https://ci.yebilly.me/login +\end{minted} {\small \begin{tabularx}{\linewidth}{L{5.2cm}L{1.9cm}Y} @@ -364,7 +468,7 @@ The provisioned dashboard \emph{Group 1 SRE} uses Eastern time (\texttt{America/New\_York}), a 6-hour default range, 30\,s refresh, and the private data source \texttt{http://prometheus:9090}. It was written for this deployment, not imported, and its definition is versioned as -\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/commit/b6cf08061815acd628bf3caaa90e38c46d57a8e7/monitoring/grafana/dashboards/sre.json}{\texttt{sre.json}}. Table~\ref{Table:SREPanels} lists the six +\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring/grafana/dashboards/sre.json}{\texttt{sre.json}}. Table~\ref{Table:SREPanels} lists the six required panels and the optional seventh with their queries; Figure~\ref{Figure:SREDashboard} shows them. In the queries, \texttt{R} stands for the root-filesystem selector @@ -471,7 +575,7 @@ lab observation window, evaluated separately for Gitea and Jenkins. An \gls{sla} is a promise to a customer, usually with consequences if missed; this project makes no SLA. The \gls{error-budget} is the failure the SLO still allows, here 1\% of the window's probes. The approach follows the -Google SRE Workbook.\footnote{\url{https://sre.google/workbook/implementing-slos/}} +Google SRE Workbook~\cite{SREWorkbook}. The 99\% figure is an exercise target, not a reliability promise. \paragraph{Worked example (hypothetical numbers from the instructor).} @@ -524,25 +628,35 @@ day's only failures, Jenkins would reach $2{,}869/2{,}880 = 99.62\%$ and use \index{runbook} \paragraph{Rules.} -Both rules are Grafana-managed and provisioned from -\texttt{grafana/provisioning/alerting/sre.yaml} (Table~\ref{Table:SRERules}). -They are evaluated every 30\,s, matching the scrape interval. Missing data -counts as \emph{Alerting} rather than healthy, and a query error sets the -\emph{Error} state, which also notifies. A missing probe series or failed -collection therefore reaches the team, but a stopped Grafana cannot alert -anyone (Section~\ref{Section:SREIncident}). +The instructor's two required rules, plus one collection-health rule, are +Grafana-managed and provisioned from +\texttt{grafana/provisioning/alerting/sre.yaml}~\cite{GrafanaAlerting} (Table~\ref{Table:SRERules}). +All are evaluated every 30\,s, matching the scrape interval. For each rule, +a query that returns no data counts as \emph{Alerting} rather than healthy, +and a query error sets the \emph{Error} state, which also notifies. One case +is not covered by that setting alone: \emph{HTTPS service down} queries both +probe series together, so if only one of them disappeared while the other +remained, Grafana would mark the missing one \emph{MissingSeries} and resolve +it. \emph{Monitoring target down} closes that gap: every scrape target, +including each HTTPS probe target, has its own \texttt{up} series, so a +stopped exporter or an unreachable probe is reported per target. A stopped +Grafana still cannot alert anyone (Section~\ref{Section:SREIncident}). {\small -\begin{tabularx}{\linewidth}{L{2.6cm}YY} +\begin{tabularx}{\linewidth}{L{2.0cm}YYY} \caption{Alert rules\label{Table:SRERules}}\\ -\toprule & \textbf{HTTPS service down} & \textbf{Root disk space low}\\ \midrule -Owner / severity & Billy (backup Vincent) / critical & Billy (backup Vincent) / warning\\ -Query & \texttt{probe\_success} of the \texttt{https} job, one instance per service & Panel~3's query (percent available on the root filesystem)\\ -Condition / pending & below 1 for 1\,minute & below 15 for 5\,minutes\\ -No data / error & Alerting / Error & Alerting / Error\\ -Notification & \texttt{team-alerts}; group by alert and instance & \texttt{team-alerts}; group by alert\\ -Timing & group wait 10\,s, group interval 1\,m, repeat 4\,h & same\\ -Runbook & \href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring/README.md\#runbook-https-service-down}{README: HTTPS service down} & \href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring/README.md\#runbook-root-disk-space-low}{README: Root disk space low}\\ +\toprule & \textbf{HTTPS service down} & \textbf{Root disk space low} & \textbf{Monitoring target down}\\ \midrule +\endfirsthead +\toprule & \textbf{HTTPS service down} & \textbf{Root disk space low} & \textbf{Monitoring target down}\\ \midrule +\endhead +Summary & ``\textit{instance} HTTPS probe is failing'' & ``Root filesystem on The-Ocean below 15\% free'' & ``\textit{job} target \textit{instance} is not being collected''\\ +Owner / severity & Billy (backup Vincent) / critical & Billy (backup Vincent) / warning & Billy (backup Vincent) / critical\\ +Query & \texttt{probe\_success} of the \texttt{https} job, one instance per service & Panel~3's query (percent available on the root filesystem) & \texttt{up}, one series per scrape target\\ +Condition / pending & below 1 for 1\,minute & below 15 for 5\,minutes & below 1 for 1\,minute\\ +No data / error & Alerting / Error & Alerting / Error & Alerting / Error\\ +Notification & \texttt{team-alerts}; group by alert and instance & \texttt{team-alerts}; group by alert & \texttt{team-alerts}; group by alert\\ +Timing & group wait 10\,s, group interval 1\,m, repeat 4\,h & same & same\\ +Runbook & \href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring/README.md\#runbook-https-service-down}{README} & \href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring/README.md\#runbook-root-disk-space-low}{README} & \href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring/README.md\#runbook-monitoring-target-down}{README}\\ \bottomrule \end{tabularx}} @@ -550,8 +664,32 @@ The worst-case time from an outage to a notification is about one scrape (30\,s) plus one evaluation (30\,s) plus the pending period (60\,s) plus the group wait (10\,s): 2~minutes 10~seconds. The 15\% disk threshold is about 3.7\,GB of the 24.9\,GB disk: enough time to clear build cache, journals, or -old images before Gitea, Jenkins, or Prometheus fail to write. The runbooks -say who acts and what to try first, and never to use \texttt{down -v}. +old images before Gitea, Jenkins, or Prometheus fail to write. + +\paragraph{Runbooks.} +The owner (Billy; Vincent as backup) first acknowledges in +\texttt{\#devops-alerts} with name and time, then: +\begin{itemize}[nosep] +\item \emph{HTTPS service down.} Check on the dashboard whether one or both +services are down and whether scrape health is also failing (then the cause is +collection, not the service). On the droplet: \texttt{cd \textasciitilde/gitea +\&\& docker compose ps} and \texttt{docker compose logs -{}-tail=50 +}. A stopped container: \texttt{docker compose start }; a +running but failing one: \texttt{docker compose restart }. Confirm the +probe returns to 1, the resolved message arrives, and, for Jenkins, that a +pipeline run passes. +\item \emph{Root disk space low.} Run \texttt{df -h /} and \texttt{docker system df}; +clear build cache (\texttt{docker builder prune}), journals +(\texttt{journalctl -{}-vacuum-size=200M}), and unused images. Never delete +volumes; if Prometheus is the cause, lower its size limit. Plan a disk resize +with the team if space cannot be recovered. +\item \emph{Monitoring target down.} The \texttt{job} label names the +collector (\texttt{blackbox}/\texttt{https}: Blackbox Exporter; \texttt{node}; +\texttt{prometheus}). In \texttt{\textasciitilde/monitoring}: \texttt{docker +compose ps} and logs, then \texttt{start} or \texttt{restart} the service. +Until it resolves, treat the dashboard and the other alerts as partly blind. +\end{itemize} +No runbook step uses \texttt{docker compose down -v}. \paragraph{Contact point.} The \gls{contact-point} \texttt{team-alerts} uses Grafana's Discord integration @@ -562,7 +700,8 @@ was sent at 15:05:55 through the replacement endpoint, which uses the stored URL without exposing it (command in the README). Grafana returned \texttt{status success} and the test message reached \texttt{\#devops-alerts} (Figure~\ref{Figure:SREContactTest}). This proves delivery only. The rules -and routing were proven by the two tests below. +and routing were proven by the capacity and collection tests below and by +the Jenkins outage in Section~\ref{Section:SREIncident}. \begin{figure}[H] \centering @@ -603,8 +742,33 @@ after the 15\% threshold was restored (right).} \label{Figure:SREDiskAlert} \end{figure} -The availability rule was tested by the controlled incident in the next -section. +\paragraph{Collection-health test.} +At 17:34:44 Blackbox Exporter was stopped (\texttt{docker compose stop +blackbox-exporter}). The first failed scrape followed at 17:34:56; by 17:35:07 +the \texttt{blackbox} target and both \texttt{https} targets read +\texttt{up = 0}, and no \texttt{probe\_success} series existed at all. At +1:36~p.m.\ Eastern Discord received \emph{Monitoring target down} for +\texttt{blackbox-exporter:9115} and, in the same minute, \emph{HTTPS service +down} for both login URLs with \texttt{grafana\_state\_reason = NoData}: with +every probe series gone, the availability rule's no-data policy fired as +designed. At 1:37~p.m.\ the collection alert was updated to all three +targets (\texttt{[FIRING:3]}). Blackbox Exporter was started again at +17:37:52, all five targets were up at 17:38:25, and Discord received +\emph{Resolved} for both rules by 1:39~p.m.\ (Figure~\ref{Figure:SRECollection}). + +\begin{figure}[H] +\centering +\includegraphics[width=0.49\linewidth]{images/discord-collection-firing-2026-10-28.png}\hfill +\includegraphics[width=0.49\linewidth]{images/discord-collection-resolved-2026-10-28.png} +\caption{October 28, 2026, 1:36--1:39 p.m.\ Eastern: collection test. Left: +\emph{Monitoring target down} for Blackbox Exporter and \emph{HTTPS service +down} fired by missing data (\texttt{NoData}). Right: \emph{Monitoring target +down} resolved for all three affected targets.} +\label{Figure:SRECollection} +\end{figure} + +The availability rule's real-outage test was the controlled incident in the +next section. %--------------------------------------------------------------- \section{Incident and Recovery} @@ -619,8 +783,11 @@ command: \texttt{cd \textasciitilde/gitea \&\& docker compose start jenkins}. Billy, as owner, acknowledged and approved the restart; Claude ran the commands. Before starting, the team confirmed that no build was running. The exercise would be ended early if anything else failed or it ran past about -8 minutes. +8 minutes. It ran 4~minutes 48~seconds, longer than the planned three, +because the restart waited for the owner's acknowledgement of the alert; that +stayed inside the 8-minute limit, and no other service was affected. +\clearpage \paragraph{Timeline.} Table~\ref{Table:SREIncident} combines Prometheus sample times, Grafana rule states polled every 6\,s, the Jenkins log, and Discord timestamps, all in UTC. @@ -680,10 +847,19 @@ At 16:11:46 the Jenkins and Gitea login pages returned 200 from Billy's laptop. Billy then pushed \texttt{b6cf080}. Gitea's webhook started Jenkins build~\#2 (pending status 16:36:27), and the build passed at 16:37:08 after 33.9\,s with both tests passing. This proves the webhook, the pipeline, and -the status report back to Gitea after the outage. The manual-PDF workflow -runs only on pushes to \texttt{main}, on Vincent's laptop runner, so it is -checked when this branch is merged; the PDF's title-page build suffix -identifies that run. +the status report back to Gitea after the outage. The changes then went +through the established review gate as +\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/pulls/22}{PR~\#22} +(\texttt{feature/issue-19-monitoring} into \texttt{main}): the required +check \texttt{vpn-dns-gateway/pipeline/pr-main} passed (on the manual commit +at 17:12:32), and Vincent approved at 17:09; Gitea dismisses an approval +as stale when later commits arrive, so branch protection requires a fresh +approval of the final head before the merge can happen. The manual-PDF workflow runs only on pushes to \texttt{main}, on +Vincent's laptop runner, so its post-outage run is the merge build that +produced this PDF; the title-page build suffix +(\texttt{+build.}\textit{run}\texttt{.}\textit{commit}) identifies that run +and the merge commit, listed under +\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/actions}{Gitea Actions}. \paragraph{How this differs from a failed build.} In \ChapterRef{JenkinsCI}, PR~\#15's deliberate unit-test failure @@ -707,7 +883,7 @@ link and the failing URL. \emph{Measurement gaps:} the acknowledgement was given to the operator rather than posted in Discord before the restart, so its exact time is not timestamped in the channel; the next exercise should acknowledge in the channel first. Probe timing is limited to 30\,s samples. -The 1.5-minute Jenkins start-up and the swap pressure in +The minute-long Jenkins start-up and the swap pressure in Section~\ref{Section:SREDashboard} share one cause: too little memory. \emph{Shared failure domain:} monitoring runs on the same droplet, so a whole-droplet outage would silence collection and alerts together, and the @@ -735,9 +911,16 @@ deployment; replaced by \texttt{.Labels}. (3) The provisioned contact point had no \emph{Test} button and the old endpoint was removed, so the new endpoint was found and documented. (4) One SLO query was first evaluated at the wrong time (16:23) and was rerun at 16:13. (5) The dashboard's CPU line -was ambiguous under swap pressure, so an I/O-wait line was added. One failed -Grafana administrator login, from a password read with untrimmed whitespace, -occurred at about 15:04 while finding the API route. +was ambiguous under swap pressure, so an I/O-wait line was added. An +independent review of the chapter draft then found: (6) a claim that a missing +probe series always alerts, which was untested and not true for a single +series, so the collection-health rule was added and tested; (7) the initial +Grafana administrator password had not been replaced, so it was; (8) Blackbox +Exporter ran as root, so it now runs as \texttt{nobody}; and smaller gaps in +the diagram, host checks, runbooks, citations, and four wrong figures, all +corrected in this version. One failed Grafana administrator login, from a +password read with untrimmed whitespace, occurred at about 15:04 while finding +the API route. \paragraph{Cost, ownership, and cleanup.} No paid service was added. The droplet stays on its 1\,GiB Basic plan (listed @@ -755,11 +938,12 @@ and the Discord webhook. The four disabled host services can be restored with \paragraph{Document controls.} This chapter was added in version 5.0. Document History records it with the updated title and abstract; \ChapterRef{HostsPasswords} adds the monitoring -host details, \texttt{metrics.yebilly.me}, the Grafana administrator, and the -Discord webhook; new glossary terms are indexed; and AI assistance is recorded -in \ChapterRef{AIPromptLog}. The reviewed configuration is commit -\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/commit/b6cf08061815acd628bf3caaa90e38c46d57a8e7}{\texttt{b6cf080}} -on \texttt{feature/issue-19-monitoring}; the merge commit and the Gitea Actions -run that built this PDF are identified by the build suffix on the title page. +host details, \texttt{metrics.yebilly.me}, the Grafana accounts, and the +Discord webhook; new glossary terms are indexed; sources are cited in the +Bibliography; and AI assistance is recorded in \ChapterRef{AIPromptLog}. The +reviewed source is the head of +\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/pulls/22}{PR~\#22}, +merged into \texttt{main}; the merge commit and the Gitea Actions run that +built this PDF are identified by the build suffix on the title page. \endgroup diff --git a/manual/latex/images/discord-collection-firing-2026-10-28.png b/manual/latex/images/discord-collection-firing-2026-10-28.png new file mode 100644 index 0000000..82b0f35 Binary files /dev/null and b/manual/latex/images/discord-collection-firing-2026-10-28.png differ diff --git a/manual/latex/images/discord-collection-resolved-2026-10-28.png b/manual/latex/images/discord-collection-resolved-2026-10-28.png new file mode 100644 index 0000000..8c213b5 Binary files /dev/null and b/manual/latex/images/discord-collection-resolved-2026-10-28.png differ diff --git a/monitoring/EVIDENCE.md b/monitoring/EVIDENCE.md index 22e5839..dde9571 100644 --- a/monitoring/EVIDENCE.md +++ b/monitoring/EVIDENCE.md @@ -141,3 +141,31 @@ undo: systemctl unmask multipathd fwupd udisks2 ModemManager && systemctl enable ## Grafana accounts - 2026-10-28 17:03:14 UTC Billy created Grafana user vsun1 (Vincent Sun), org role Viewer, not server admin. Org users: billy Admin, vsun1 Viewer. + +## Grafana administrator password replaced + +- ~17:2x UTC Billy changed the billy password in Grafana (Profile -> Change password); the new value is only in his password manager and Grafana's database. +- 17:29:34 UTC the previous value (still in the running container's environment) returned HTTP 401 on /api/user: the initial credential is no longer valid. +- GF_SECURITY_ADMIN_PASSWORD line removed from ~/monitoring/.env.secret (now only DISCORD_WEBHOOK_URL; mode 600 root); `docker compose config --quiet` valid. The stale value leaves the container environment at the next Grafana recreate. + +## Audit follow-up checks 2026-10-28 (UTC) + +- Baseline detail (first sample 04:34:10): free -b available 154066944 B (146.9 MiB), swap used 434180096 B (414.1 MiB); second sample 04:34:27 available 229351424 B (218.7 MiB). Docker 29.8.1, Compose v5.5.1, kernel 6.8.0-147-generic. +- 14:56 target check: all five targets up, lastError none, lastScrapeDuration 0.031-0.226 s. +- 17:30:59 CPU counters, /proc/stat (USER_HZ 100) vs node_cpu_seconds_total: user 4100.8 / 4099.5 s, system 1768.9 / 1768.0, idle 562052.6 / 562034.4, iowait 2080.2 / 2078.2, steal 1727.5 / 1726.4 (difference consistent with the <=30 s scrape age). +- 17:3x targets: blackbox 0.004 s, https git 0.128 s, https ci 0.064 s, node 0.062 s, prometheus 0.022 s; all up, no error. +- Container identities and mounts: prometheus uid 65534 (nobody), /prometheus = volume monitoring_prometheus_data, /etc/prometheus/prometheus.yml bind ro; grafana uid 472, /var/lib/grafana = volume monitoring_grafana_data, /etc/grafana/provisioning and /var/lib/grafana-dashboards bind ro; node-exporter uid 65534, /host bind ro; blackbox-exporter uid 0 (image default), /config/blackbox.yml bind ro -> changed to user 65534:65534 (see below). + +## Collection-health rule and non-root Blackbox (UTC) + +- Local smoke run: new rule "Monitoring target down" (expr `up`, < 1 for 1 m, no data -> Alerting, error -> Error) loaded healthy and went Pending for the absent node target; blackbox-exporter as uid 65534 probed successfully. +- 17:33:23 deployed sre.yaml (third rule), compose.yaml (blackbox `user: "65534:65534"`), README (runbook, password prompt); `docker compose up -d grafana blackbox-exporter`. 17:33:57 "finished to provision alerting", no errors. blackbox id uid=65534(nobody). Old admin password no longer in the Grafana container environment. 17:34:15 all five targets up. + +## Collection-health test: Blackbox Exporter stopped (UTC; EDT = UTC-4) + +- Pre: up blackbox=1, prometheus=1, https=1 (x2), node=1. +- 17:34:44 INJECT `docker compose stop blackbox-exporter`. +- 17:34:56 first failed scrape: up blackbox=0, one https target 0; 17:35:07 both https targets 0; count(probe_success) returned no series from 17:35:07 until the restore (probe series absent, not 0). +- 17:37:52 RESTORE `docker compose start blackbox-exporter`; 17:38:25 all five targets up; blackbox uid 65534. +- Grafana alert state could not be read through the API (admin password now known only to Billy); notifications are evidenced by the Discord screenshots. +- Discord #devops-alerts (screenshots), EDT: 1:36 PM "[FIRING:1] Monitoring target down" instance blackbox-exporter:9115 job blackbox, A=0; same minute "[FIRING:1] HTTPS service down" for ci and for git with grafana_state_reason=NoData, A=-1 (probe series absent -> no-data policy Alerting); 1:37 PM "[FIRING:3] Monitoring target down" (blackbox plus both https targets); RESOLVED (A=1) for HTTPS service down git and ci (1:39 PM for ci) and "[RESOLVED] Monitoring target down" for all three at 1:39 PM. diff --git a/monitoring/README.md b/monitoring/README.md index 874420c..371e716 100644 --- a/monitoring/README.md +++ b/monitoring/README.md @@ -26,8 +26,10 @@ GF_SECURITY_ADMIN_PASSWORD= DISCORD_WEBHOOK_URL= ``` -The admin password applies only when Grafana first creates its database; later -changes are made in Grafana and recorded in the password manager. +The admin password applies only when Grafana first creates its database. At +first login, change it in Grafana (Profile → Change password), store the new +value in the password manager, and delete the `GF_SECURITY_ADMIN_PASSWORD` +line from `.env.secret`; on The-Ocean this was done on 28 Oct 2026. ## Deploy @@ -70,7 +72,7 @@ retries scrapes. All four services restart `unless-stopped`. ```bash GIP=$(docker inspect monitoring-grafana-1 --format '{{(index .NetworkSettings.Networks "monitoring_monitoring").IPAddress}}') - P=$(docker exec monitoring-grafana-1 printenv GF_SECURITY_ADMIN_PASSWORD) + read -rs -p 'Grafana password for billy: ' P; echo # typed, never stored curl -s -u "billy:$P" -H 'Content-Type: application/json' -X POST \ -d '{"integration":{"uid":"team-alerts-discord","type":"discord","version":"v1","settings":{},"secureFields":{"url":true}}}' \ "http://$GIP:3000/apis/notifications.alerting.grafana.app/v1beta1/namespaces/default/receivers/dGVhbS1hbGVydHM/test" @@ -91,10 +93,27 @@ retries scrapes. All four services restart `unless-stopped`. (volumes kept), then revert the `metrics` block and probe allowlist entry in `deploy/Caddyfile` and recreate Caddy. +## Runbook: Monitoring target down + +Alert `Monitoring target down` (critical, owner Billy, backup Vincent): a +Prometheus scrape target (`up`) has failed for 1 minute, or no target data +exists. While it fires, the dashboard and the other alerts are partly blind. + +1. Acknowledge in `#devops-alerts` with your name and the time. +2. The `job` label names the broken collector: `blackbox` or `https` means + Blackbox Exporter, `node` means Node Exporter, `prometheus` means Prometheus. +3. On the droplet: `cd ~/monitoring && docker compose ps`, then + `docker compose logs --tail=50 `. +4. Stopped: `docker compose start `. Running but failing: + `docker compose restart `. Never use `down -v`. +5. Confirm all targets are up again (dashboard *Scrape health* panel) and that + Discord shows the resolved message. + ## Runbook: HTTPS service down Alert `HTTPS service down` (critical, owner Billy, backup Vincent): a login -page's `probe_success` has been 0 for 1 minute, or the probe series is missing. +page's `probe_success` has been 0 for 1 minute. If the probe series disappears +instead, this rule can resolve; `Monitoring target down` reports that case. 1. Acknowledge in `#devops-alerts` with your name and the time. 2. Open the `Group 1 SRE` dashboard. Is only one service down, or both? diff --git a/monitoring/compose.yaml b/monitoring/compose.yaml index 91f72bd..b9a0d38 100644 --- a/monitoring/compose.yaml +++ b/monitoring/compose.yaml @@ -72,6 +72,7 @@ services: blackbox-exporter: image: quay.io/prometheus/blackbox-exporter:v0.29.1@sha256:ea1c7aa3ef3f307cd03e85f34abb604478ccb90b567fc690da0cd9776da76b13 restart: unless-stopped + user: "65534:65534" # image default is root; HTTP probes need no privileges command: ["--config.file=/config/blackbox.yml"] volumes: - ./blackbox/blackbox.yml:/config/blackbox.yml:ro diff --git a/monitoring/grafana/provisioning/alerting/sre.yaml b/monitoring/grafana/provisioning/alerting/sre.yaml index 3e62ca4..fa79229 100644 --- a/monitoring/grafana/provisioning/alerting/sre.yaml +++ b/monitoring/grafana/provisioning/alerting/sre.yaml @@ -86,3 +86,39 @@ groups: group_wait: 10s group_interval: 1m repeat_interval: 4h + + # Collection health: one series per scrape target, so a stopped exporter or a + # probe series that disappears is reported instead of silently resolving. + - uid: monitoring-target-down + title: Monitoring target down + condition: C + data: + - refId: A + relativeTimeRange: {from: 300, to: 0} + datasourceUid: prometheus + model: + refId: A + expr: up + instant: true + - refId: C + datasourceUid: __expr__ + model: + refId: C + type: threshold + expression: A + conditions: + - evaluator: {type: lt, params: [1]} + for: 1m + noDataState: Alerting # no up series at all: Prometheus has lost every target + execErrState: Error # Prometheus itself unreachable + labels: {severity: critical, owner: billy} + annotations: + summary: "{{ .Labels.job }} target {{ .Labels.instance }} is not being collected" + description: "Prometheus could not scrape this target for 1 minute; panels and alerts that depend on it are blind. Owner: Billy (backup: Vincent)." + runbook_url: https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring/README.md#runbook-monitoring-target-down + notification_settings: + receiver: team-alerts + group_by: [alertname] + group_wait: 10s + group_interval: 1m + repeat_interval: 4h