Add Prometheus/Grafana monitoring and SRE manual chapter (Assignment 7) #22

Merged
bill merged 5 commits from feature/issue-19-monitoring into main 2026-10-28 18:18:36 +00:00
32 changed files with 2362 additions and 32 deletions
+9 -1
View File
@@ -10,8 +10,16 @@ colors.yebilly.me {
# Jenkins: Stevens campus network (155.246.0.0/16) plus team and approved grader # Jenkins: Stevens campus network (155.246.0.0/16) plus team and approved grader
# IPs from CI_TEAM_IPS in the untracked .env. Everyone else gets 403 before login. # IPs from CI_TEAM_IPS in the untracked .env. Everyone else gets 403 before login.
# The Stevens VPN is split-tunnel, so it does not give visitors a 155.246.x.x address. # The Stevens VPN is split-tunnel, so it does not give visitors a 155.246.x.x address.
# 172.30.90.10 is Blackbox Exporter on the private probe network (monitoring/compose.yaml).
ci.yebilly.me { ci.yebilly.me {
@denied not remote_ip 155.246.0.0/16 {$CI_TEAM_IPS} @denied not remote_ip 155.246.0.0/16 172.30.90.10/32 {$CI_TEAM_IPS}
respond @denied 403 respond @denied 403
reverse_proxy jenkins:8080 reverse_proxy jenkins:8080
} }
# Grafana (Assignment 7): same allowlist as Jenkins, then Grafana's own login.
metrics.yebilly.me {
@denied not remote_ip 155.246.0.0/16 {$CI_TEAM_IPS}
respond @denied 403
reverse_proxy grafana:3000
}
+10
View File
@@ -35,6 +35,9 @@ services:
# Jenkins resolves git.yebilly.me to Caddy here, so checkout and status # Jenkins resolves git.yebilly.me to Caddy here, so checkout and status
# calls stay on the droplet instead of hairpinning through the public IP. # calls stay on the droplet instead of hairpinning through the public IP.
aliases: [git.yebilly.me] aliases: [git.yebilly.me]
probe:
# Blackbox Exporter (monitoring/compose.yaml) probes both sites through Caddy here.
aliases: [git.yebilly.me, ci.yebilly.me]
depends_on: [gitea] depends_on: [gitea]
# Jenkins LTS controller (Assignment 6). Builds run on its single executor. # Jenkins LTS controller (Assignment 6). Builds run on its single executor.
@@ -66,3 +69,10 @@ volumes:
networks: networks:
web: web:
# Fixed subnet so Blackbox Exporter can have a fixed address (172.30.90.10), the only
# private address the ci.yebilly.me allowlist admits. The web subnet stays denied:
# Docker's proxy presents IPv6 and hairpin visitors as its gateway, 172.18.0.1.
probe:
ipam:
config:
- subnet: 172.30.90.0/28
+12 -9
View File
@@ -1,10 +1,13 @@
This group document records the SSW 590 coursework and its supporting This group document records the SSW 590 coursework and its supporting
commands, designs, and evidence. Assignment 6 adds continuous integration: commands, designs, and evidence. Assignment 7 introduces site reliability
a Jenkins LTS controller runs beside Gitea on the DigitalOcean droplet, engineering: Prometheus, Grafana OSS, Node Exporter, and Blackbox Exporter
reachable at \url{https://ci.yebilly.me/login} from approved networks only. run as four pinned containers beside Gitea and Jenkins on the 1\,GiB
A Gitea pull request triggers a private webhook; Jenkins tests the pull DigitalOcean droplet, with Grafana at \url{https://metrics.yebilly.me/login}
request's latest head commit with a versioned \texttt{Jenkinsfile} and for approved networks only. A dashboard shows host CPU, memory, and disk and
reports a named status check that branch protection requires before merge. the HTTPS availability of Gitea and Jenkins. A 99\% availability objective is
A deliberate unit-test failure blocked pull request \#15, a repair passed, defined and measured, and three alert rules (service availability, disk
and the change was reviewed and merged. Earlier chapters retain the group's space, and collection health) notify the team's Discord channel. Each was
prior assignment results, including the Gitea Actions manual build. 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.
+61
View File
@@ -679,3 +679,64 @@ changed. The revision is checked through the complete local TinyTeX build,
diagnostic inspection, and visual review of the affected PDF pages. diagnostic inspection, and visual review of the affected PDF pages.
No commit, push, remote configuration change, or submission is performed No commit, push, remote configuration change, or submission is performed
as part of this correction. as part of this correction.
\section{Assignment 7 Monitoring Deployment, Tests, and Chapter}
Date: October 27--28, 2026; Tool: Anthropic Claude Code (Claude Opus 5.5);
Human: Billy Ye, with Vincent Sun as verifier and reviewer.
Inputs: instructor manual version 1.42 (Chapter 5), found in Billy's
downloads after Billy asked to implement ``chapter 5 of this manual''; the
repository and its AI guidance; Billy's decisions (measure capacity before
any resize and then try a capped deployment on the 1\,GiB plan, alerts to a
Discord webhook, hostname \texttt{metrics.yebilly.me}, Claude running droplet
commands over SSH with Billy approving each step, disabling four unused host
services after Claude showed the disk and boot checks); Billy's DNS record,
Discord channel and webhook, issue \#19, secrets file, Grafana login,
screenshots, pushes, and improvement issues \#20 and \#21.
Claude synced both checkouts, measured the baseline, chose and verified
pinned image digests, wrote the \texttt{monitoring/} configuration, the
Caddy and Compose changes, the dashboard, alert rules, and README runbooks;
validated them locally (Compose, \texttt{promtool}, \texttt{caddy validate},
and a throwaway Grafana run); deployed them after backing up the Caddy files;
ran the exposure, contact-point, capacity-alert, outage, persistence, and SLO
queries; and wrote \ChapterRef{SREMonitoring}, the Hosts and Passwords
updates, glossary terms, title page, abstract, and Document History. Billy
typed every secret himself: Claude never saw the Grafana password or the
webhook URL. API calls read the password from the Grafana container's
environment without printing it.
Human/AI corrections: the local Grafana run rejected an alert template
written with \texttt{\$\$labels}; the deployed Grafana could not read its
configuration after the Windows upload (fixed with \texttt{chmod}); Grafana~13
had removed the old contact-point test endpoint, so the replacement was found
from its own error message; one Grafana login from Claude failed because a
password was read from the file with untrimmed whitespace; the first
build-check before the outage matched the \texttt{ps} header and aborted
before anything was stopped; one SLO query was first evaluated at the wrong
time and was rerun; Billy's partial home IP address was removed from the
evidence file before commit; the push from Claude's shell failed
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.
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 --
Group''), with the spelling of Prometheus corrected; the acknowledgement was given to Claude before the restart, and
Billy's Discord reply came later; Billy created Vincent's Grafana
account \texttt{vsun1} as Viewer; the 24-hour SLO was not evaluated; the manual-PDF build needs
Vincent's runner when the branch is merged. No pull request, merge, or
submission was performed by Claude.
+7 -6
View File
@@ -34,15 +34,15 @@
\definecolor{devopsLightBlue}{RGB}{232,240,247} \definecolor{devopsLightBlue}{RGB}{232,240,247}
% Replace these values for each assignment. % Replace these values for each assignment.
\newcommand{\AssignmentTitle}{Gitea + Jenkins Autobuild and Testing -- Group} \newcommand{\AssignmentTitle}{Grafana and Prometheus SRE -- Group}
\newcommand{\AssignmentNumber}{6} \newcommand{\AssignmentNumber}{7}
\newcommand{\DocumentVersion}{4.2} \newcommand{\DocumentVersion}{5.0}
\newcommand{\DocumentStatus}{Draft} \newcommand{\DocumentStatus}{Draft}
\newcommand{\CourseNumber}{SSW 590} \newcommand{\CourseNumber}{SSW 590}
\newcommand{\CourseName}{DevOps} \newcommand{\CourseName}{DevOps}
\newcommand{\Authors}{Vincent Sun and Billy Ye} \newcommand{\Authors}{Vincent Sun and Billy Ye}
\newcommand{\Organization}{Stevens Institute of Technology} \newcommand{\Organization}{Stevens Institute of Technology}
\newcommand{\DocumentDate}{10/23/2026} \newcommand{\DocumentDate}{10/28/2026}
\newcommand{\DueDate}{Friday by 11:59pm} \newcommand{\DueDate}{Friday by 11:59pm}
% CI writes this ignored file in its checkout; ordinary local builds stay unchanged. % CI writes this ignored file in its checkout; ordinary local builds stay unchanged.
\providecommand{\CIBuildSuffix}{} \providecommand{\CIBuildSuffix}{}
@@ -147,11 +147,12 @@
\include{devopsGitea} \include{devopsGitea}
\include{devopsAutomatedManualBuild} \include{devopsAutomatedManualBuild}
\include{devopsJenkins} \include{devopsJenkins}
\include{devopsSRE}
\include{devopsHostsPasswords} \include{devopsHostsPasswords}
% Restore when a chapter cites devopsReferences.bib. % Restore when a chapter cites devopsReferences.bib.
%\bibliographystyle{IEEEtran} \bibliographystyle{IEEEtran}
%\bibliography{devopsReferences} \bibliography{devopsReferences}
\appendix \appendix
\include{devopsDocumentGuide} \include{devopsDocumentGuide}
+1
View File
@@ -12,6 +12,7 @@ link each entry to the changed chapter, table, figure, or controlled artifact.
\multicolumn{4}{l}{\small\itshape Document Update History (continued)}\\ \multicolumn{4}{l}{\small\itshape Document Update History (continued)}\\
\toprule \textbf{Date / Version} & \textbf{Author Initials} & \textbf{Change} & \textbf{Changed At}\\ \midrule \toprule \textbf{Date / Version} & \textbf{Author Initials} & \textbf{Change} & \textbf{Changed At}\\ \midrule
\endhead \bottomrule \endlastfoot \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, 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.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 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}\\ 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}\\
+9
View File
@@ -3,6 +3,9 @@
\newacronym{cd}{CD}{continuous delivery or continuous deployment} \newacronym{cd}{CD}{continuous delivery or continuous deployment}
\newacronym{iac}{IaC}{infrastructure as code} \newacronym{iac}{IaC}{infrastructure as code}
\newacronym{slo}{SLO}{service-level objective} \newacronym{slo}{SLO}{service-level objective}
\newacronym{sli}{SLI}{service-level indicator}
\newacronym{sla}{SLA}{service-level agreement}
\newacronym{sre}{SRE}{site reliability engineering}
\newacronym{vpn}{VPN}{virtual private network} \newacronym{vpn}{VPN}{virtual private network}
\newacronym{dns}{DNS}{Domain Name System} \newacronym{dns}{DNS}{Domain Name System}
\newacronym{swot}{SWOT}{strengths, weaknesses, opportunities, and threats} \newacronym{swot}{SWOT}{strengths, weaknesses, opportunities, and threats}
@@ -30,3 +33,9 @@
\newglossaryentry{jenkinsfile}{name={Jenkinsfile},description={A version-controlled file at the repository root that defines a Jenkins pipeline's stages and steps}} \newglossaryentry{jenkinsfile}{name={Jenkinsfile},description={A version-controlled file at the repository root that defines a Jenkins pipeline's stages and steps}}
\newglossaryentry{controller}{name={controller},description={The central Jenkins server that serves the web interface, stores configuration, and schedules builds; it can also run builds on its own executors}} \newglossaryentry{controller}{name={controller},description={The central Jenkins server that serves the web interface, stores configuration, and schedules builds; it can also run builds on its own executors}}
\newglossaryentry{build-agent}{name={build agent},description={A separate machine or container that connects to a Jenkins controller and runs builds, isolating build code from the controller}} \newglossaryentry{build-agent}{name={build agent},description={A separate machine or container that connects to a Jenkins controller and runs builds, isolating build code from the controller}}
\newglossaryentry{error-budget}{name={error budget},description={The amount of failure an SLO still allows in its window; for a 99\% target over 2,880 probes, 28.8 failed probes}}
\newglossaryentry{exporter}{name={exporter},description={A small service that exposes measurements of another system, such as a host or a probed website, in Prometheus format for scraping}}
\newglossaryentry{scrape}{name={scrape},description={Prometheus's periodic HTTP request to a target's metrics endpoint, which records each returned value with a timestamp}}
\newglossaryentry{contact-point}{name={contact point},description={A Grafana alerting destination, such as a Discord channel, that receives firing and resolved notifications}}
\newglossaryentry{blameless-review}{name={blameless review},description={An incident review that records impact, timeline, cause, and improvements without assigning personal blame}}
+43 -16
View File
@@ -15,41 +15,62 @@ October 22--23, 2026 (\ChapterRef{JenkinsCI}) the droplet record was updated
for the 1\,GiB resize, the Jenkins service, and \texttt{ci.yebilly.me}; the for the 1\,GiB resize, the Jenkins service, and \texttt{ci.yebilly.me}; the
Color Buttons app was marked retired; and the Passwords table gained the Color Buttons app was marked retired; and the Passwords table gained the
Jenkins administrators, the \texttt{jenkins-bot} Gitea account, and its token. Jenkins administrators, the \texttt{jenkins-bot} Gitea account, and its token.
On October 28, 2026 (\ChapterRef{SREMonitoring}) the droplet record gained
the four monitoring containers, \texttt{metrics.yebilly.me}, the second swap
file, and real monitoring status; the Passwords table gained the Grafana
accounts, the monitoring secrets file, and the Discord webhook.
\section{Hosts} \section{Hosts}
\small \small
\begin{tabularx}{\linewidth}{@{}L{3.3cm}Y@{}} \begin{tabularx}{\linewidth}{@{}L{3.3cm}Y@{}}
\caption{Hosts\label{Table:Hosts}}\\ \caption{Hosts\label{Table:Hosts}}\\
\toprule \textbf{Field} & \textbf{Droplet The-Ocean (git.yebilly.me, ci.yebilly.me)}\\ \midrule \toprule \textbf{Field} & \textbf{Droplet The-Ocean (git, ci, metrics .yebilly.me)}\\ \midrule
\endfirsthead \endfirsthead
\toprule \textbf{Field} & \textbf{Droplet The-Ocean (git.yebilly.me, ci.yebilly.me)}\\ \midrule \toprule \textbf{Field} & \textbf{Droplet The-Ocean (git, ci, metrics .yebilly.me)}\\ \midrule
\endhead \endhead
\bottomrule \endlastfoot \bottomrule \endlastfoot
Role & Gitea work hub (Gitea 1.27.3 behind Caddy 2.11.4 TLS proxy); since Role & Gitea work hub (Gitea 1.27.3 behind Caddy 2.11.4 TLS proxy); since
22 Oct 2026 also the Jenkins 2.580.1 LTS controller, which runs the CI builds. 22 Oct 2026 also the Jenkins 2.580.1 LTS controller, which runs the CI builds;
The Assignment 3 Color Buttons app (29 Sep 2026) is retired: container since 28 Oct 2026 also the monitoring stack (Prometheus 3.15.1, Grafana OSS
13.2.5, Node Exporter 1.12.1, Blackbox Exporter 0.29.1). The Assignment 3 Color Buttons app (29 Sep 2026) is retired: container
stopped with restart policy \texttt{no}; its Caddy route remains\\ stopped with restart policy \texttt{no}; its Caddy route remains\\
Environment & Course production (team use)\\ Environment & Course production (team use)\\
Provider & DigitalOcean, NYC1; Ubuntu 24.04 LTS; 1 vCPU; resized from Provider & DigitalOcean, NYC1; Ubuntu 24.04 LTS; 1 vCPU; resized from
512\,MB to the 1\,GiB Basic plan in October 2026 (961\,MiB reported, 25\,GB 512\,MB to the 1\,GiB Basic plan in October 2026 (961\,MiB reported, 25\,GB
plan disk, 1\,GiB swap file)\\ plan disk); swap files \texttt{/swapfile} and \texttt{/swapfile2}, 1\,GiB
each (second added 28 Oct 2026); \texttt{multipathd}, \texttt{fwupd},
\texttt{udisks2}, and \texttt{ModemManager} disabled and masked\\
Public address / DNS & IPv4 \texttt{147.182.178.136}; \texttt{A} records Public address / DNS & IPv4 \texttt{147.182.178.136}; \texttt{A} records
\texttt{git}, \texttt{ci}, and \texttt{colors} \texttt{.yebilly.me}; public \texttt{git}, \texttt{ci}, \texttt{metrics}, and \texttt{colors} \texttt{.yebilly.me}; public
IPv6 \texttt{2604:a880:400:d1:0:5:22d:6001} assigned but not published in DNS\\ IPv6 \texttt{2604:a880:400:d1:0:5:22d:6001} assigned but not published in DNS\\
Private services & Gitea \texttt{:3000} and Jenkins \texttt{:8080} (512\,MiB Private services & Gitea \texttt{:3000} and Jenkins \texttt{:8080} (512\,MiB
RAM, 0.75 CPU cap; agent port disabled) on Docker network \texttt{gitea\_web}, RAM, 0.75 CPU cap; agent port disabled) on Docker network \texttt{gitea\_web},
no host ports; SQLite file in volume \texttt{gitea\_gitea-data}; Jenkins state no host ports; SQLite file in volume \texttt{gitea\_gitea-data}; Jenkins state
in volume \texttt{gitea\_jenkins-home}\\ 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; 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
\texttt{monitoring\_grafana\_data}\\
Exposed ports & 443/TCP and 80/TCP to all; 22/TCP to approved team addresses only Exposed ports & 443/TCP and 80/TCP to all; 22/TCP to approved team addresses only
(Cloud Firewall \texttt{gitea-fw}); \texttt{ci.yebilly.me} answers only (Cloud Firewall \texttt{gitea-fw}); \texttt{ci.yebilly.me} and
Stevens 155.246.0.0/16 and team addresses (Caddy allowlist), 403 otherwise\\ \texttt{metrics.yebilly.me} answer only Stevens 155.246.0.0/16 and team
addresses (Caddy allowlist; \texttt{ci} also the probe address), 403
otherwise; monitoring ports 9090, 9100, 9115 not reachable\\
Owner & BY (server administration); VS (review)\\ Owner & BY (server administration); VS (review)\\
HTTPS URLs & \url{https://git.yebilly.me}, \url{https://ci.yebilly.me/login}\\ HTTPS URLs & \url{https://git.yebilly.me}, \url{https://ci.yebilly.me/login},
\url{https://metrics.yebilly.me/login}\\
Backup status & No backup job; container-replacement persistence verified for Backup status & No backup job; container-replacement persistence verified for
Gitea (\ChapterRef{GiteaFoundation}) and restart persistence for Jenkins Gitea (\ChapterRef{GiteaFoundation}), restart persistence for Jenkins
(\ChapterRef{JenkinsCI}) only\\ (\ChapterRef{JenkinsCI}) and for Prometheus and Grafana
Monitoring status & No alerting configured; checked manually with (\ChapterRef{SREMonitoring}); manual volume backup procedure in
\texttt{docker compose ps}, \texttt{docker stats}, and logs\\ \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}, \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} \end{tabularx}
\normalsize \normalsize
@@ -90,6 +111,10 @@ 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{billy} & BY & BY's password manager & Administer (all)\\
Jenkins \texttt{vsun1} & VS & VS'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\\ 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; 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 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\\ 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\\ DigitalOcean team & BY, VS & Each member's own login, in their password manager & Team member\\
Namecheap (\texttt{yebilly.me}) & BY & BY's password manager & Domain owner\\ Namecheap (\texttt{yebilly.me}) & BY & BY's password manager & Domain owner\\
@@ -99,8 +124,10 @@ Gitea database (SQLite) & --- & No credential; file access limited to droplet \t
\end{tabularx} \end{tabularx}
\normalsize \normalsize
Multi-factor authentication and rotation status have not yet been recorded for Multi-factor authentication: as reported by BY on 28 Oct 2026, his Discord
these accounts. Some credentials also have local copies on members' devices; account (which owns the \texttt{\#devops-alerts} webhook) and his GitHub
account use MFA. MFA status for the other accounts, and rotation status for
all of them, has not yet been recorded. Some credentials also have local copies on members' devices;
moving them into the password managers is an open follow-up. moving them into the password managers is an open follow-up.
\fussy \fussy
+43
View File
@@ -4,3 +4,46 @@
publisher = {IT Revolution Press}, publisher = {IT Revolution Press},
year = {2018} 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}
}
+980
View File
@@ -0,0 +1,980 @@
\chapter{Introduction to SRE: Monitoring and Reliability}
\ChapterLabel{SREMonitoring}
\index{SRE}
\index{monitoring}
\index{Prometheus}
\index{Grafana}
\begingroup
\sloppy
This chapter records Assignment 7, \emph{Grafana and Prometheus SRE --
Group} (instructor manual version 1.42, Chapter 5, \emph{Introduction to SRE:
Monitoring and Reliability}), the course's introduction to \gls{sre}. Four new
containers now run beside Gitea, Jenkins, and Caddy on the droplet
\texttt{The-Ocean}: Prometheus collects time-series metrics, Node Exporter
reports whole-droplet CPU, memory, and disk, Blackbox Exporter probes the
Gitea and Jenkins HTTPS login pages, and Grafana OSS shows the dashboard and
sends alerts to the team's Discord channel. The work was carried out on
October 28, 2026 under
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/issues/19}{issue~\#19}
on branch \texttt{feature/issue-19-monitoring}, starting from \texttt{main}
at \href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/commit/9b0dc4d}{\texttt{9b0dc4d}}, whose Jenkins and manual-build checks had passed. Billy
implemented it with Claude Code running droplet commands that Billy approved;
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/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, 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}).
\end{devopsNote}
%---------------------------------------------------------------
\section{Deployment and Reproducibility}
\label{Section:SREDeployment}
\index{monitoring!deployment}
\paragraph{Baseline and capacity decision.}
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
written abort limits: stop the stack if available memory stayed below
50\,MiB, swap use exceeded 1.5\,GiB, the kernel killed a process for lack of
memory, or a login page took more than about 5\,s. To make room without
losing a service, four unused Ubuntu services were disabled and masked
(\texttt{multipathd}, \texttt{fwupd}, \texttt{udisks2},
\texttt{ModemManager}; the disk is a single virtio device with no multipath
or boot dependency), and a second 1\,GiB swap file (\texttt{/swapfile2}) was
added. During the first two and a half minutes after start-up, available memory stayed
at 156--230\,MiB and swap use reached 707\,MiB; no out-of-memory kill
occurred. The trial therefore became the deployment. Section~\ref{Section:SREDashboard}
shows its cost: frequent swap-in wait.
\paragraph{Versions and images.}
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/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
versioned with it. The pulled \texttt{RepoDigests} matched the pins. Grafana
13.3.0 had been released the day before and was skipped for the 13.2 line's
security patch release.
\begin{table}[H]
\centering\footnotesize
\caption{Monitoring images (amd64), pulled October 28, 2026\label{Table:SREImages}}
\begin{tabular}{@{}L{2.9cm}L{4.6cm}L{2.6cm}L{4.4cm}@{}}
\toprule \textbf{Container} & \textbf{Image : tag} & \textbf{Digest} & \textbf{Memory cap / state}\\ \midrule
Prometheus & \nolinkurl{prom/prometheus:v3.15.1} & \texttt{fa330227\ldots91a2} & 128\,MiB; volume \nolinkurl{monitoring_prometheus_data}\\
Grafana OSS & \nolinkurl{grafana/grafana:13.2.5} & \texttt{9f7aa1e1\ldots8a84} & 192\,MiB; volume \nolinkurl{monitoring_grafana_data}\\
Node Exporter & \nolinkurl{quay.io/prometheus/node-exporter:v1.12.1} & \texttt{1b4e4438\ldots1be0} & 32\,MiB; none\\
Blackbox Exporter & \nolinkurl{quay.io/prometheus/blackbox-exporter:v0.29.1} & \texttt{ea1c7aa3\ldots6b13} & 32\,MiB; none\\
\bottomrule
\end{tabular}
\end{table}
\noindent Full pulled digests (\texttt{RepoDigests}, identical to the pins in
\texttt{compose.yaml}):
\begin{minted}[breaklines,fontsize=\footnotesize]{text}
prom/prometheus sha256:fa3302279710be2f21a8301ec17a8b4f2301fd829bd113839b3b6b02b6f191a2
grafana/grafana sha256:9f7aa1e1e3246aade5792d35a738049f7f32f89cd51d1956cf426a4e86268a84
quay.io/prometheus/node-exporter sha256:1b4e4438faca4dd7e001dd445d161a4a2091b0fededa84093b3a8dfeae1f1be0
quay.io/prometheus/blackbox-exporter sha256:ea1c7aa3ef3f307cd03e85f34abb604478ccb90b567fc690da0cd9776da76b13
\end{minted}
\paragraph{Retention and storage.}
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
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 Node
Exporter sit only on the private \texttt{monitoring} network (Docker name
\texttt{monitoring\_monitoring}); Blackbox Exporter also joins the probe
network described below. Grafana also
joins Caddy's network \texttt{gitea\_web} so Caddy can reach it; no
monitoring container publishes a host port, so the Grafana loopback port in
the instructor's example is not used. Blackbox Exporter joins a small private
network, \texttt{gitea\_probe} (172.30.90.0/28), where it has the fixed
address 172.30.90.10 and Caddy answers as \texttt{git.yebilly.me} and
\texttt{ci.yebilly.me}.
\begin{figure}[H]
\centering
\resizebox{\linewidth}{!}{%
\begin{tikzpicture}[
box/.style={draw, rounded corners, align=center, font=\small, minimum height=1.0cm},
new/.style={box, fill=devopsLightBlue},
lbl/.style={font=\scriptsize, fill=white, inner sep=1pt},
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}\\{\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);
\draw[arr] (caddy.north) |- (gitea.west);
\draw[arr] (caddy.east) -- ++(0.55,0) coordinate (bus) |- (jenkins.west);
\draw[arr] (bus) |- node[lbl, pos=0.75, above=1pt]{HTTP} (grafana.west);
\draw[arr, devopsBlue] (grafana.south) -- node[lbl, right=2pt]{query API} (prom.north);
\draw[arr, devopsBlue] (prom.west) -- node[lbl, above=3pt]{scrape} (bbox.east);
\draw[arr, devopsBlue] (prom.east) -- node[lbl, above=3pt]{scrape} (node.west);
\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) (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\_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. 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/branch/main/monitoring}{\texttt{monitoring/}}
folder holds the Compose file, \texttt{prometheus/prometheus.yml},
\texttt{blackbox/blackbox.yml}, Grafana provisioning (data source, dashboard
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. 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
whole-droplet metrics.
\paragraph{Start-up and maintenance.}
The deploy sequence, run on October 28, was:
\begin{minted}[breaklines]{sh}
cd ~/gitea && docker compose up -d --no-deps caddy # creates gitea_probe, new routes
cd ~/monitoring # copied from the laptop with scp
find grafana prometheus blackbox -type d -exec chmod 755 {} + \
&& find grafana prometheus blackbox -type f -exec chmod 644 {} +
docker compose config --quiet
docker compose pull
docker compose run --rm --no-deps --entrypoint /bin/promtool \
prometheus check config /etc/prometheus/prometheus.yml # SUCCESS
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. 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
\mbox{\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 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:3.22 tar czf /b/monitoring-$(date -u +%Y%m%dT%H%M%SZ).tgz /g /p
docker compose start grafana prometheus
# restore (stack stopped): empty both volumes, then
# docker run --rm -v monitoring_grafana_data:/g -v monitoring_prometheus_data:/p \
# -v /root/backups:/b alpine:3.22 tar xzf /b/monitoring-<stamp>.tgz -C /
\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 (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.
%---------------------------------------------------------------
\section{Metrics and Probes}
\label{Section:SREMetrics}
\index{Prometheus!scrape targets}
\index{Blackbox Exporter}
\paragraph{Scrape configuration.}
Prometheus takes one \gls{scrape} from each target every 30\,s. Four jobs
cover Prometheus itself, the two \glspl{exporter} (Node Exporter, and
Blackbox Exporter's own metrics), and the HTTPS probes. The probe job
uses the multi-target pattern: each URL becomes the probe target and the
\texttt{instance} label, and the scrape goes to Blackbox Exporter:
\begin{minted}[breaklines]{yaml}
- job_name: https
metrics_path: /probe
params: {module: [http_2xx]}
static_configs:
- targets: [https://git.yebilly.me/user/login, https://ci.yebilly.me/login]
relabel_configs:
- {source_labels: [__address__], target_label: __param_target}
- {source_labels: [__param_target], target_label: instance}
- {target_label: __address__, replacement: blackbox-exporter:9115}
\end{minted}
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
certificate valid for the hostname (\texttt{insecure\_skip\_verify: false},
\texttt{fail\_if\_not\_ssl: true}), redirects followed, and a final 2xx status
within 10\,s. It checks the login page's status, not its content, so a
successful probe does not prove Git operations, sign-in, or a working build.
Both probes returned 200 with \texttt{probe\_success = 1} (Gitea 0.19\,s,
Jenkins 0.69\,s). The certificate expiry is also exported
(\texttt{probe\_ssl\_earliest\_cert\_expiry}).
\paragraph{Probe route.}
Blackbox Exporter resolves \texttt{git.yebilly.me} and
\texttt{ci.yebilly.me} through Docker's network aliases to Caddy on
\texttt{gitea\_probe}, so each probe passes through Caddy, TLS, and the real
virtual host, but not public DNS, the Cloud Firewall, or any outside network.
It therefore cannot detect a public DNS or Internet routing failure (improvement
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/issues/20}{issue~\#20}).
Because \texttt{ci.yebilly.me} is allowlisted, the Caddyfile admits exactly
the probe's address, \texttt{172.30.90.10/32}. Allowing the whole Docker
network would have been unsafe: Docker's user-space proxy presents IPv6 and
hair-pinned visitors with a network gateway address (first 172.18.0.1, now
172.30.90.1), and that address must stay denied. Table~\ref{Table:SREExposure}
confirms it is.
\paragraph{Host metric verification.}
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
\texttt{\{job="node",mountpoint="/",fstype="ext4"\}}. Its size,
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. 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
\caption{Metric inventory used by the dashboard and alerts\label{Table:SREInventory}}
\begin{tabular}{@{}L{3.4cm}L{1.5cm}L{3.0cm}L{3.0cm}L{3.3cm}@{}}
\toprule \textbf{Metric} & \textbf{Type, unit} & \textbf{Labels used} & \textbf{Meaning} & \textbf{Limitation}\\ \midrule
\nolinkurl{node_cpu_seconds_total} & counter, seconds & \texttt{job="node"}, \texttt{cpu}, \texttt{mode} & CPU time per mode since boot & Graph its rate, never the raw total; whole host, not per container\\
\nolinkurl{node_memory_MemAvailable_bytes} & gauge, bytes & \texttt{job="node"}, \texttt{instance} & Kernel estimate of memory available to new work without swapping & Not the same as unused RAM\\
\nolinkurl{node_filesystem_avail_bytes}, \nolinkurl{_size_bytes} & gauge, bytes & \nolinkurl{device="/dev/vda1"}, \nolinkurl{fstype="ext4"}, \nolinkurl{mountpoint="/"} & Free space usable by non-root users; filesystem size & Must select the real root filesystem\\
\texttt{up} & gauge, 0/1 & \texttt{job}, \texttt{instance} & Prometheus reached the target & 1 for the probe job does not mean the probed site is up\\
\texttt{probe\_success} & gauge, 0/1 & \texttt{job="https"}, \texttt{instance}=URL & Probe met the success criteria & Login page only, from inside the droplet\\
\nolinkurl{probe_duration_seconds} & gauge, seconds & \texttt{job="https"}, \texttt{instance}=URL & Time of the whole probe & One sample per 30\,s; misses short spikes\\
\bottomrule
\end{tabular}
\end{table}
No Gitea or Jenkins application metrics were enabled; the optional extension
was not attempted.
%---------------------------------------------------------------
\section{HTTPS and Access Control}
\label{Section:SREAccess}
\index{Grafana!access control}
\paragraph{Login URLs.}
\begin{itemize}[nosep]
\item Gitea: \url{https://git.yebilly.me/user/login}
\item Jenkins: \url{https://ci.yebilly.me/login}
\item Grafana: \url{https://metrics.yebilly.me/login}
\end{itemize}
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
(\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$
147.182.178.136 at Namecheap (Figure~\ref{Figure:SREDNS}). When Caddy was
recreated at 14:40:57--14:41:09 with the new site block, it obtained the Let's
Encrypt certificate for \texttt{metrics.yebilly.me} automatically. Git and
Jenkins answered 200 immediately afterwards.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.9\linewidth]{images/namecheap-metrics-dns-2026-10-28.png}
\caption{October 28, 2026: Namecheap host records for \texttt{yebilly.me}
with the new \texttt{metrics} \texttt{A} record next to \texttt{git} and
\texttt{ci}.}
\label{Figure:SREDNS}
\end{figure}
\paragraph{Proxy changes.}
The Caddyfile gained one site block and one allowlist entry (excerpt; the
team addresses come from the untracked \texttt{\textasciitilde/gitea/.env}):
\begin{minted}[breaklines]{text}
ci.yebilly.me {
@denied not remote_ip 155.246.0.0/16 172.30.90.10/32 {$CI_TEAM_IPS}
respond @denied 403
reverse_proxy jenkins:8080
}
metrics.yebilly.me {
@denied not remote_ip 155.246.0.0/16 {$CI_TEAM_IPS}
respond @denied 403
reverse_proxy grafana:3000
}
\end{minted}
Grafana's own \texttt{/metrics} endpoint is disabled
(\texttt{GF\_METRICS\_ENABLED=false}). The Cloud Firewall \texttt{gitea-fw}
and the inactive host firewall are unchanged: no rule was needed, because no
monitoring port is published. Before the change, the old Compose file and
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 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}
\caption{External exposure tests, October 28, 2026\label{Table:SREExposure}}\\
\toprule \textbf{Test} & \textbf{Expected} & \textbf{Actual}\\ \midrule
TCP 3000, 3001, 8080, 9090, 9100, 9115, 50000 on the droplet's IPv4 & no connection & no connection on all 7 \StatusPass\\
Same 7 ports on the droplet's IPv6 & no connection & no connection on all 7 \StatusPass\\
\texttt{https://metrics\ldots/login} over IPv4 (allowlisted) & 200 & 200 \StatusPass\\
\texttt{http://metrics.yebilly.me} & redirect & 308 to HTTPS \StatusPass\\
Grafana API without login (\texttt{/api/dashboards/\ldots}, data-source proxy query) & 401 & 401, 401 \StatusPass\\
\texttt{https://metrics\ldots/metrics} & no metrics & 302 to the login page \StatusPass\\
\texttt{https://git\ldots/metrics}; \texttt{https://ci\ldots/prometheus/} & no metrics & 404; 403 \StatusPass\\
\texttt{ci} and \texttt{metrics} login over IPv6 (not allowlisted; proxy gateway address) & 403 & 403, 403 \StatusPass\\
\texttt{git} login over IPv6 & 200 & 200 \StatusPass\\
\bottomrule
\end{tabularx}}
%---------------------------------------------------------------
\section{Dashboard and CI Correlation}
\label{Section:SREDashboard}
\index{Grafana!dashboard}
\paragraph{Dashboard.}
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/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
\texttt{job="node",mountpoint="/",fstype="ext4"}, the same in numerator and
denominator, and \texttt{G} and \texttt{J} for the Gitea and Jenkins login
URLs.
{\small
\begin{tabularx}{\linewidth}{L{3.6cm}L{1.6cm}Y}
\caption{Dashboard panels\label{Table:SREPanels}}\\
\toprule \textbf{Panel} & \textbf{Unit} & \textbf{Reading}\\ \midrule
1. Droplet CPU utilization & percent & Busy share averaged over CPUs, plus how much of it is waiting on disk (I/O wait); red line at 80\%\\
2. Available memory & bytes & \texttt{MemAvailable}; line at 100\,MiB marks low headroom\\
3. Root filesystem available & percent & Available over size of the verified root filesystem; line at 15\%\\
4. Gitea HTTPS availability & 0/1 & \texttt{probe\_success}, shown as UP/DOWN\\
5. Jenkins HTTPS availability & 0/1 & \texttt{probe\_success}, shown as UP/DOWN\\
6. HTTPS probe duration & seconds & One labelled line per service\\
7. Scrape health (optional) & 0/1 & \texttt{up}, one line per target\\
\bottomrule
\end{tabularx}}
\begin{minted}[breaklines]{text}
1 100 * (1 - avg(rate(node_cpu_seconds_total{job="node",mode="idle"}[2m])))
100 * avg(rate(node_cpu_seconds_total{job="node",mode="iowait"}[2m]))
2 node_memory_MemAvailable_bytes{job="node"}
3 100 * node_filesystem_avail_bytes{R} / node_filesystem_size_bytes{R}
4 probe_success{job="https",instance="G"}
5 probe_success{job="https",instance="J"}
6 probe_duration_seconds{job="https",instance="G"}
probe_duration_seconds{job="https",instance="J"}
7 up
\end{minted}
\begin{figure}[htbp]
\centering
\includegraphics[width=\linewidth]{images/grafana-dashboard-2026-10-28.png}
\caption{October 28, 2026, 10:47--11:01 a.m.\ Eastern: \emph{Group 1 SRE}
about ten minutes after start-up, with all seven panels receiving data. The
flat lines in the CPU, memory, and disk panels are thresholds (80\%,
100\,MiB, 15\%), not data. This capture predates the I/O-wait line added to
panel~1 later that day (Figure~\ref{Figure:SREBuildWindow}).}
\label{Figure:SREDashboard}
\end{figure}
\paragraph{Normal build compared with host metrics.}
Billy's push of \texttt{d3a5e6b} triggered Jenkins job
\texttt{vpn-dns-gateway~»~feature/issue-19-monitoring}, build~\#1: queued
15:17:33.9 (webhook), started 15:17:41.3, finished 15:17:53.1 (11.8\,s),
\texttt{SUCCESS} with both unit tests passing. It ran on the Jenkins
controller's single executor, inside the droplet's measurements; there is no
remote agent. Table~\ref{Table:SREBuild} compares 30\,s samples before,
during, and after; each CPU value is a rate over the preceding minute, so
only the 15:18:00 and 15:18:30 samples include the build.
Figure~\ref{Figure:SREBuildWindow} shows the same window; its CPU panel uses
a 2-minute rate, so its peaks (about 65\% near 11:02 Eastern) differ from
the table's 1-minute values. No Grafana annotation was added: the dashboard
is provisioned read-only, so the build is marked by the timestamps here and
in the figure caption. Step~1 asks for one build to be observed before
deployment; the pre-deployment baseline (Section~\ref{Section:SREDeployment})
was a static reading without a build, so this post-deployment build is the
team's build observation.
\begin{table}[H]
\centering\footnotesize
\caption{Host metrics around build \#1 (UTC)\label{Table:SREBuild}}
\begin{tabular}{@{}lrrrl@{}}
\toprule \textbf{Sample} & \textbf{CPU busy (1\,m)} & \textbf{Available} & \textbf{Swap used} & \textbf{Phase}\\ \midrule
15:16:00 & 15.0\% & 169\,MiB & 695\,MiB & before\\
15:16:30 & 8.3\% & 175\,MiB & 688\,MiB & before\\
15:17:00 & 39.4\% & 104\,MiB & 650\,MiB & before (background burst)\\
15:17:30 & 19.0\% & 116\,MiB & 675\,MiB & before (queued 15:17:33.9)\\
15:18:00 & 32.1\% & 196\,MiB & 691\,MiB & \textbf{during} (window holds the build)\\
15:18:30 & 43.7\% & 221\,MiB & 680\,MiB & \textbf{during} (window holds the build)\\
15:19:00 & 46.4\% & 133\,MiB & 652\,MiB & after (background burst)\\
15:19:30 & 21.4\% & 181\,MiB & 692\,MiB & after\\
15:20:00 & 17.1\% & 221\,MiB & 702\,MiB & after\\
\bottomrule
\end{tabular}
\end{table}
No change can be attributed to the build. It lasted less than one scrape
interval, and the two samples whose windows contain it lie inside the
8--49\% range seen without any build. Whole-host metrics also cannot attribute CPU or memory to Jenkins
rather than another container. The table does show a background pattern:
about every two minutes, CPU rose to 35--49\% and available memory fell by
80--120\,MiB. Sampling each container every 8\,s showed them mostly under
2\% CPU, with short bursts when Gitea's memory jumped from 23 to 93\,MiB and
Grafana's from 73 to 140\,MiB. Over 15 minutes the CPU modes were 74.3\% idle,
\textbf{14.7\% I/O wait}, 4.5\% system, 4.0\% user, and 1.6\% hypervisor steal.
The busy line is therefore mostly memory being paged back in from swap, not
computation. The dashboard was then changed to add the I/O-wait line to
panel~1, so it shows this directly. The same pressure explains a Gitea probe
of about 1.9\,s, one Grafana request that failed after 4\,s, and the later
build~\#2 taking 34\,s.
\begin{figure}[H]
\centering
\includegraphics[width=\linewidth]{images/grafana-build-window-2026-10-28.png}
\caption{October 28, 2026, 11:00--11:30 a.m.\ Eastern: the build ran at
11:17:41--11:17:53 with no visible effect. The I/O-wait line (yellow) follows
the CPU-busy line, and both services stay UP.}
\label{Figure:SREBuildWindow}
\end{figure}
%---------------------------------------------------------------
\section{SLI, SLO, and Error Budget}
\label{Section:SRESLO}
\index{SLO}
\index{error budget}
\paragraph{Definitions.}
A \gls{sli} is a measurement; here, the fraction of scheduled HTTPS probes
of one service that succeed in a stated window. A \gls{slo} is the team's
own target for that measurement: at least 99\% probe success over a 24-hour
lab observation window, evaluated separately for Gitea and Jenkins. A
\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~\cite{SREWorkbook}.
The 99\% figure is an exercise target, not a reliability promise.
\paragraph{Worked example (hypothetical numbers from the instructor).}
At one probe every 30\,s, 24 hours contain $24 \times 120 = 2{,}880$ probes per
service. Suppose Gitea succeeds on all 2{,}880, and Jenkins succeeds on
2{,}850 and fails on 30, with no missing samples. Gitea's SLI is
$2{,}880/2{,}880 = 100\%$. Jenkins' is $2{,}850/2{,}880 = 98.96\%$, which
misses 99\%. The budget is $1\% \times 2{,}880 = 28.8$ failed probes, which
is $28.8 \times 30\,\text{s} = 864\,\text{s} = 14.4$ minutes if failures are
spread like the samples. Thirty failures exceed it by 1.2 probes, about
0.6 minutes. Failures come in whole probes, so 28 is the most that still
meets the target ($28/2{,}880 = 0.97\%$; 29 would be 1.01\%).
\paragraph{Measured short window.}
The window is the 10 minutes from 16:03:00 to 16:13:00 UTC on October 28,
which contains the whole Jenkins outage and recovery. The queries were
evaluated at 16:13:00 with a 30\,s scrape interval, so about 20 samples per
service were expected:
\begin{minted}[breaklines]{text}
100 * avg_over_time(probe_success{job="https",instance="<login URL>"}[10m])
count_over_time(probe_success{job="https",instance="<login URL>"}[10m])
sum_over_time(probe_success{job="https",instance="<login URL>"}[10m])
\end{minted}
\begin{table}[H]
\centering\footnotesize
\caption{Probe success, 16:03:00--16:13:00 UTC, October 28, 2026\label{Table:SREWindow}}
\begin{tabular}{@{}lrrrr@{}}
\toprule \textbf{Service} & \textbf{Expected} & \textbf{Received} & \textbf{Successful} & \textbf{Success}\\ \midrule
Gitea & 20 & 20 & 20 & 100\%\\
Jenkins & 20 & 20 & 9 & 45\%\\
\bottomrule
\end{tabular}
\end{table}
All expected samples arrived (16:03:20 to 16:12:50), so the window has no
unknown time. If samples had been missing, they would be reported as missing,
never counted as successes. Jenkins' 11 failed samples (16:05:20--16:10:20)
correspond to about 5.5 minutes of failed probes. This shows what the SLI
measures during a known outage. It cannot show whether the 24-hour SLO was
met, which would need a full day of collection, and the optional full-day
evaluation was not performed. As an illustration only: if those 11 were the
day's only failures, Jenkins would reach $2{,}869/2{,}880 = 99.62\%$ and use
11 of the 28.8-probe budget.
%---------------------------------------------------------------
\section{Alerts and Runbooks}
\label{Section:SREAlerts}
\index{alerting}
\index{runbook}
\paragraph{Rules.}
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.0cm}YYY}
\caption{Alert rules\label{Table:SRERules}}\\
\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}}
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.
\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
<service>}. A stopped container: \texttt{docker compose start <service>}; a
running but failing one: \texttt{docker compose restart <service>}. 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
(Figure~\ref{Figure:SREWebhook}); resolved notifications are enabled. Because
it is provisioned, Grafana shows no \emph{Test} button for it, and Grafana~13
has removed the older test endpoint (it answers \texttt{410 Gone}). The test
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 capacity and collection tests below and by
the Jenkins outage in Section~\ref{Section:SREIncident}.
\begin{figure}[H]
\centering
\includegraphics[width=0.8\linewidth]{images/discord-webhook-2026-10-28.png}
\caption{October 28, 2026: the Discord webhook \texttt{Grafana} posting to
\texttt{\#devops-alerts}. The URL is not shown.}
\label{Figure:SREWebhook}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=0.75\linewidth]{images/discord-contact-point-test-2026-10-28.png}
\caption{October 28, 2026, 11:05 a.m.\ Eastern: contact-point test received
in Discord.}
\label{Figure:SREContactTest}
\end{figure}
\paragraph{Capacity rule test.}
The disk was not filled. Instead, at 15:36:48 the threshold on the droplet's
copy of the rule file was raised from 15 to 70 (free space was 61.3\%), and
Grafana's alerting provisioning was reloaded without a restart. The rule went
\emph{Pending} at 15:36:50 and \emph{Firing} at 15:41:50, exactly the 5-minute
pending period, and Discord received the notification at 11:42 a.m.\ Eastern
(Figure~\ref{Figure:SREDiskAlert}). At 15:42:24 the file was restored to 15 and
reloaded; the instance cleared by 15:42:41 and Discord received
\emph{Resolved}. Git held 15 throughout, and the restored file's SHA-256
matched the committed one. The resolved message carries
\texttt{grafana\_state\_reason = Updated}: Grafana resolved it because the
rule changed back, and at that moment 61.3\% free space was well above 15\%.
\begin{figure}[H]
\centering
\includegraphics[width=0.49\linewidth]{images/discord-disk-alert-firing-2026-10-28.png}\hfill
\includegraphics[width=0.49\linewidth]{images/discord-disk-alert-resolved-2026-10-28.png}
\caption{October 28, 2026, 11:42 a.m.\ Eastern: \emph{Root disk space low}
firing (left; value 61.3\% under the temporary 70\% threshold) and resolved
after the 15\% threshold was restored (right).}
\label{Figure:SREDiskAlert}
\end{figure}
\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.32\linewidth]{images/discord-collection-firing-2026-10-28.png}\hfill
\includegraphics[width=0.32\linewidth]{images/discord-collection-resolved-2026-10-28.png}\hfill
\includegraphics[width=0.32\linewidth]{images/discord-collection-https-resolved-2026-10-28.png}
\caption{October 28, 2026, 1:36--1:39 p.m.\ Eastern: collection test (states
and values are transcribed in the text). Left: \emph{Monitoring target
down} for Blackbox Exporter and \emph{HTTPS service down} fired by missing
data (\texttt{NoData}). Middle: \emph{Monitoring target down} resolved for
all three targets. Right: \emph{HTTPS service down} resolved for Jenkins,
value \texttt{A=1}.}
\label{Figure:SRECollection}
\end{figure}
The availability rule's real-outage test was the controlled incident in the
next section.
%---------------------------------------------------------------
\section{Incident and Recovery}
\label{Section:SREIncident}
\index{incident!Jenkins outage exercise}
\index{blameless review}
\paragraph{Plan.}
The exercise stopped only Jenkins, for about three minutes and long enough to
notify. Gitea and monitoring stayed up, and no volume was touched. Recovery
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. 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.
{\small
\begin{tabularx}{\linewidth}{L{2.2cm}Y}
\caption{Jenkins outage exercise, October 28, 2026 (UTC)\label{Table:SREIncident}}\\
\toprule \textbf{Time} & \textbf{Event}\\ \midrule
16:05:00 & \textbf{Injection}: \texttt{docker compose stop jenkins} (stopped 16:05:06)\\
16:05:20 & \textbf{First failing probe} sample (\texttt{probe\_success = 0}); the probe's HTTP status is 502 from Caddy through 16:09:50\\
16:05:54 & Rule instance \texttt{ci} observed \emph{Pending}\\
16:06:52 & Rule \textbf{firing} (\emph{Alerting})\\
16:07 & \textbf{Notification} in \texttt{\#devops-alerts}, 12:07 p.m.\ Eastern (Figure~\ref{Figure:SREIncidentAlerts})\\
16:07--16:09 & \textbf{Acknowledgement}: Billy confirmed receipt to the operator; his Discord reply came after the restart\\
16:09:48 & \textbf{Restart}: \texttt{docker compose start jenkins}\\
16:10:20 & Probe receives no HTTP response (status 0) while Jenkins is starting\\
16:10:45 & Jenkins log: ``Jenkins is fully up and running''\\
16:10:50 & \textbf{First successful probe} sample\\
16:11:27 & Rule instance \texttt{ci} observed \emph{Normal}\\
16:12 & \textbf{Resolved} notification, 12:12 p.m.\ Eastern, value \texttt{A=1}\\
\bottomrule
\end{tabularx}}
\paragraph{Measured response.}
Taking the injection as the start, the first failed probe came after 20\,s,
the rule fired after 1~minute 52~seconds, and the notification arrived after
about 2~minutes. That is within the 2~minutes 10~seconds that the settings
allow. From the restart, Jenkins was fully up after 57\,s, the first
successful probe came after 62\,s, and the rule returned to normal after about
1.5~minutes. Probes failed for 5~minutes 30~seconds in total (16:05:20 to
16:10:50). The Gitea probe stayed at 1 throughout.
Figure~\ref{Figure:SREOutage} shows the outage on the dashboard.
\begin{figure}[H]
\centering
\includegraphics[width=0.49\linewidth]{images/discord-jenkins-down-firing-2026-10-28.png}\hfill
\includegraphics[width=0.49\linewidth]{images/discord-jenkins-down-resolved-2026-10-28.png}
\caption{October 28, 2026: \emph{HTTPS service down} for
\texttt{https://ci.yebilly.me/login}, firing at 12:07 p.m.\ (left,
\texttt{A=0}) and resolved at 12:12 p.m.\ Eastern (right, \texttt{A=1}).}
\label{Figure:SREIncidentAlerts}
\end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=\linewidth]{images/grafana-outage-2026-10-28.png}
\caption{October 28, 2026, about 12:01--1:01 p.m.\ Eastern: Jenkins
availability is DOWN from about 12:05 to 12:11 while Gitea stays UP. Available
memory rises by about 400\,MiB while Jenkins is stopped, and the Jenkins probe
duration spikes to about 9.5\,s near 12:10, when the probe received no
response while Jenkins was starting (10\,s timeout).}
\label{Figure:SREOutage}
\end{figure}
\paragraph{Recovery checks.}
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 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
(Section~\ref{Section:JenkinsReview}) had Jenkins \emph{working}: it ran the
pipeline, reported a failed status check, and branch protection blocked the
merge. Here Jenkins was \emph{unavailable}: no pipeline could run, the HTTPS
probe failed, and the monitoring alert fired. A failed build is a code
problem shown in Gitea's checks. An unavailable service is an operations
problem, and only monitoring would report it before a developer noticed a
missing check.
\paragraph{Blameless review.}
This \gls{blameless-review} covers the planned exercise. \emph{Impact:} Jenkins' web interface and new CI runs were unavailable for
about 5.5~minutes; no build was queued, so no pull request was delayed, and
Gitea and its HTTPS service were unaffected. \emph{Cause:} a planned,
announced stop of the Jenkins container. \emph{Response:} the alert reached
the team in about 2~minutes and the documented single command restored the
service in about 1~minute. \emph{What went well:} detection matched the
configured timing; the runbook command worked; the alert carried the runbook
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 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
probe never leaves the droplet. Improvements, in priority order:
\begin{enumerate}[nosep]
\item \href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/issues/20}{Issue~\#20}
(owner Vincent): add a free uptime check outside DigitalOcean for the three
HTTPS hostnames, notifying the same channel.
\item \href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/issues/21}{Issue~\#21}
(owner Billy): remove swap churn, by resizing to 2\,GiB (CPU/RAM only,
reversible, with the cost recorded) or by reducing memory use, then re-measure
I/O wait over 24 hours.
\end{enumerate}
%---------------------------------------------------------------
\section{Manual Quality and Controls}
\label{Section:SREQuality}
\paragraph{Corrective actions.}
Problems found and fixed during this work: (1) Grafana could not read its
provisioning files after the Windows \texttt{scp} upload; fixed with
\texttt{chmod} and added to the README. (2) An alert summary written with
\texttt{\$\$labels} failed Grafana's template parser in a local test run before
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. 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
at \$6/month on October 21, 2026, see \ChapterRef{JenkinsCI}); the images
use about 2.4\,GB of disk, and the second swap file 1\,GB. Billy administers
the stack; Vincent reviews and owns issue~\#20. To remove it:
\texttt{docker compose stop \&\& docker compose rm -f} in
\texttt{\textasciitilde/monitoring}, then \texttt{docker volume rm} for the two
volumes if the history is not needed; revert the \texttt{metrics} block, the
\texttt{172.30.90.10/32} allowlist entry, and the probe network in
\texttt{deploy/}, and recreate Caddy; delete the \texttt{metrics} DNS record
and the Discord webhook. The four disabled host services can be restored with
\texttt{systemctl unmask} and \texttt{systemctl enable -{}-now}.
\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 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
Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

+178
View File
@@ -0,0 +1,178 @@
# Assignment 7 raw evidence (droplet The-Ocean, captured by Claude over SSH, approved by Billy)
## Baseline 2026-10-28 04:34 UTC
Ubuntu 24.04.5 LTS, kernel 6.8.0-147-generic x86_64, 1 vCPU; Docker 29.8.1, Compose v5.5.1; disk /dev/vda1 24883167232 B, 18784387072 B available (25% used); gitea_web 172.18.0.0/16; global IPv6 2604:a880:400:d1:0:5:22d:6001/64, no AAAA records; uptime 6 days, load 0.05.
Containers: gitea-jenkins-1 325.4MiB/512MiB, gitea-caddy-1 10.85MiB, gitea-gitea-1 98.21MiB. Host RSS: java 318.1, gitea 122.0, dockerd 50.0, multipathd 26.5, containerd 23.5, caddy 16.7 MiB.
```
Wed Oct 28 04:34:27 UTC 2026
total used free shared buff/cache available
Mem: 1008177152 778825728 101543936 3424256 281452544 229351424
Swap: 1073737728 479457280 594280448
Filesystem 1B-blocks Used Available Use% Mounted on
/dev/vda1 24883167232 6082015232 18784374784 25% /
NAME TYPE SIZE USED PRIO
/swapfile file 1024M 457.2M -2
gitea-jenkins-1 0.17% 326.3MiB / 512MiB
gitea-caddy-1 0.00% 11MiB / 961.5MiB
gitea-gitea-1 0.20% 102.9MiB / 961.5MiB
```
## Unused host services disabled
```
2026-10-28 04:52:51 UTC disabled+masked: multipathd(.service,.socket), fwupd(+fwupd-refresh.timer), udisks2, ModemManager
before: Mem total 1008177152 used 798810112 available 209367040
after (04:52:59): used 786944000 available 221233152 ; 04:53:0x: available 238510080, Mlocked 0
apt-daily.service ran 04:52:52-04:53:24 (40.8M peak, triggered by systemd reload); after: available 364957696, swap used 503414784
checks before change: multipath -ll empty; dmsetup ls "No devices found"; root=UUID cc6f3ac6 (/dev/vda1, LABEL cloudimg-rootfs); multipath-tools-boot not installed; initramfs multipath files 0
post: gitea-jenkins-1, gitea-caddy-1, gitea-gitea-1 Up; git login 200 1.09s, ci login 200 0.38s
undo: systemctl unmask multipathd fwupd udisks2 ModemManager && systemctl enable --now multipathd udisks2 ModemManager
```
## Image pins chosen 2026-10-28 (registry index digests)
- prom/prometheus:v3.15.1 sha256:fa3302279710be2f21a8301ec17a8b4f2301fd829bd113839b3b6b02b6f191a2 (released 2026-10-21)
- grafana/grafana:13.2.5 sha256:9f7aa1e1e3246aade5792d35a738049f7f32f89cd51d1956cf426a4e86268a84 (2026-10-27; 13.3.0 skipped as one day old)
- quay.io/prometheus/node-exporter:v1.12.1 sha256:1b4e4438faca4dd7e001dd445d161a4a2091b0fededa84093b3a8dfeae1f1be0 (2026-07-14)
- quay.io/prometheus/blackbox-exporter:v0.29.1 sha256:ea1c7aa3ef3f307cd03e85f34abb604478ccb90b567fc690da0cd9776da76b13 (2026-10-21)
## Local validation 2026-10-28 (laptop Docker 29.8.2)
- docker compose config --quiet: monitoring and deploy valid; promtool check config SUCCESS; caddy validate: Valid configuration.
- Grafana smoke run: first run rejected "{{ $$labels.instance }}" (bad character $); fixed to {{ .Labels.instance }}; rerun: both rules health ok, probes Normal from laptop, disk rule Pending (NoData) without node-exporter, dashboard group1-sre in folder SRE.
## Deploy 2026-10-28 (UTC)
- Issue #19; branch feature/issue-19-monitoring from main 9b0dc4d (Jenkins pipeline/head + Automated Manual Build success on 9b0dc4d).
- 14:40:23 second swapfile: /swapfile2 1 GiB added (fstab); swap total 2147475456 B. Disk 24883167232 B, 17710153728 B available after.
- 14:40:40 backup ~/gitea/backup-20261028T144040Z (docker-compose.yml, Caddyfile). Staged files validated on droplet (caddy validate: Valid configuration; compose config valid). Diffs = probe network + aliases; ci allowlist +172.30.90.10/32; metrics block.
- 14:40:57-14:41:09 `docker compose up -d --no-deps caddy` (recreate). gitea_probe 172.30.90.0/28; caddy gitea_probe=172.30.90.2 (aliases git/ci), gitea_web=172.18.0.3. Let's Encrypt: "certificate obtained successfully" metrics.yebilly.me. Laptop: git 200 0.049s, ci 200 0.289s, metrics 502 (Grafana not started).
- docker-proxy now targets 172.30.90.2 (probe network) for 80/443; IPv6/hairpin clients would appear as 172.30.90.1, not allowlisted (only .10/32).
- ~/monitoring copied (700). .env.secret created by Billy: 600 root; names GF_SECURITY_ADMIN_PASSWORD, DISCORD_WEBHOOK_URL; no empty values; no "$".
- 14:50:45-14:51:51 pull. promtool: SUCCESS. RepoDigests (amd64) match pins; sizes: prometheus 381400167, grafana 1949552290, node-exporter 40992821, blackbox 58273564 B. Before up: avail 241209344 B, swap used 520241152 B; disk 39% used.
- 14:52:04-14:52:08 `docker compose up -d`. Samples (avail MiB / swap used MiB): 14:52:23 228/578, 14:52:43 230/666, 14:53:02 159/668, 14:53:22 195/692, 14:53:40 211/700, 14:53:57 218/700, 14:54:14 189/705, 14:54:32 156/707. Peaks: grafana 136.6/192 MiB, prometheus 26.6/128, blackbox 15.3/32, node-exporter 13.6/32. No OOM in dmesg. Within abort limits.
- Grafana "permission denied" on /etc/grafana/provisioning/* (scp-created 700 dirs). Fix 14:55: dirs 755 / files 644 under grafana, prometheus, blackbox; restart 14:55:08; provisioning datasources, alerting, dashboards finished.
- Targets (14:5x): prometheus, node, blackbox, https x2 all up. probe_success 1 both; status 200; duration ci 0.686s, git 0.193s.
- 14:56: rules "HTTPS service down" (ci, git Normal) and "Root disk space low" (Normal), health ok; contact point team-alerts discord url set; dashboard Group 1 SRE /d/group1-sre.
- Host verification 14:56:37: root fs labels device=/dev/vda1 fstype=ext4 mountpoint=/; size 24883167232 = df; avail 15281520640 vs df 15281516544. MemTotal 1008177152 = free total; MemAvailable 293392384 vs free available 301010944 (seconds apart).
- Laptop after start: git 200 0.53s, ci 200 0.064s, metrics /login 200 1.68s, metrics /metrics 302.
## External exposure tests 2026-10-28 14:57 UTC (Billy's laptop, home network on the team allowlist, IPv6 available)
- Raw ports 3000, 3001, 8080, 9090, 9100, 9115, 50000 on 147.182.178.136 and [2604:a880:400:d1:0:5:22d:6001]: all no connection (curl 000, 5 s connect timeout).
- https://metrics.yebilly.me/metrics -> 302 to /login?redirectTo=%2Fmetrics (GF_METRICS_ENABLED=false); /api/dashboards/uid/group1-sre -> 401; /api/datasources/proxy/uid/prometheus/api/v1/query?query=up -> 401 (no anonymous access).
- https://git.yebilly.me/metrics -> 404; https://ci.yebilly.me/prometheus/ -> 403 (no app metrics endpoints).
- http://metrics.yebilly.me -> 308 to https.
- IPv6 (--resolve to droplet IPv6, no AAAA records): ci /login 403, metrics /login 403, git /user/login 200. IPv4 from allowlisted laptop: ci 200, metrics 200. Confirms docker-proxy gateway (172.30.90.1) is not allowlisted.
## Grafana login and contact-point test 2026-10-28
- ~15:01 UTC (11:01 EDT): Billy logged in at https://metrics.yebilly.me as billy; dashboard Group 1 SRE showed all 7 panels with data (screenshot).
- Contact point is provisioned, so the UI offers no Test button. Legacy POST /api/alertmanager/grafana/config/api/v1/receivers/test -> 410 Gone ("use /apis/notifications.alerting.grafana.app/v1beta1/namespaces/{namespace}/receivers/{uid}/test").
- One failed admin auth at ~15:04 UTC from the droplet host (password read from file included compose-trimmed whitespace); later calls used the container's environment.
- 15:05:55 UTC: POST .../receivers/dGVhbS1hbGVydHM/test with integration team-alerts-discord, secureFields.url=true -> {"status":"success","duration":"866ms"}.
## Normal Jenkins build vs host metrics 2026-10-28 (UTC; EDT = UTC-4)
- Before (15:10:40): cpu 48.6% (2m rate, during a periodic burst), MemAvailable 169.3 MiB, swap used 651.4 MiB; jenkins 348.3 MiB, 0.15% CPU.
- Commit d3a5e6b pushed by Billy; Gitea statuses on d3a5e6b: pending 15:17:36, pending 15:17:51, success 15:17:53 (vpn-dns-gateway/pipeline/head).
- Jenkins vpn-dns-gateway » feature/issue-19-monitoring #1: queued 15:17:33.9, started 15:17:41.3, duration 11.825 s, finished ~15:17:53.1, SUCCESS, "Ran 2 tests ... OK". Executed on the controller (built-in node; workspace /var/jenkins_home/workspace/eway_feature_issue-19-monitoring), single executor, no agents.
- Prometheus 30 s samples 15:12:00-15:22:00 (cpu = 100*(1-avg(rate(idle[1m]))), MiB, MiB, load1):
15:12:00 38.5/186/652/0.79, 15:13:00 48.8/205/710/0.41, 15:14:00 8.3/224/708/0.15, 15:15:00 38.8/136/673/0.38, 15:16:00 15.0/169/695/0.14, 15:16:30 8.3/175/688/0.15, 15:17:00 39.4/104/650/0.29, **15:17:30 19.0/116/675/0.33, 15:18:00 32.1/196/691/0.41 (build window)**, 15:18:30 43.7/221/680/0.31, 15:19:00 46.4/133/652/0.84, 15:20:00 17.1/221/702/0.51, 15:21:00 35.7/114/651/0.47, 15:22:00 11.2/209/691/0.21.
- Result: no change attributable to the 11.8 s build; it is shorter than the 30 s scrape interval and its samples fall inside the background range (8-49%). Whole-host measurements cannot attribute CPU/RAM to Jenkins.
- Background pattern: bursts about every 2 min (CPU 35-49%, MemAvailable -80..-120 MiB). docker stats 15:23:39-15:25:47 every ~8 s: containers mostly <2% CPU; burst at 15:24:38-15:24:46 = gitea 13.7% CPU, 23->93 MiB, grafana 15.4%, 73->140 MiB, MemAvailable 118 MiB.
- CPU by mode, 15 min to ~15:26: idle 74.3%, iowait 14.7%, system 4.5%, user 4.0%, steal 1.6%. vmstat burst: si 2189 pages/s, wa 10%. Interpretation: memory pressure causes swap-in I/O wait; CPU work itself is ~8.5%.
- Dashboard v2 (15:26): CPU panel adds "of which I/O wait" = 100*avg(rate(node_cpu_seconds_total{mode="iowait"}[2m])).
## Capacity alert test (Root disk space low) 2026-10-28 (UTC; EDT = UTC-4)
- Before: rule inactive, instance Normal since 14:56:20. Root fs ~61% available. Final file backed up on the droplet.
- 15:36:48 temporary change on the droplet only: threshold `lt 15` -> `lt 70` in grafana/provisioning/alerting/sre.yaml; POST /api/admin/provisioning/alerting/reload -> "Alerting config reloaded" (no restart). Git kept 15.
- 15:36:50 Pending; polled every ~15 s; 15:41:50 Alerting/firing (pending period 5 m as configured). Notification expected ~15:42:00 (group_wait 10 s).
- 15:42:24 restored `lt 15` from the backup; reload -> "Alerting config reloaded". 15:42:41 rule inactive, no instances; Grafana Alertmanager active alerts: [] (resolved).
- Droplet rule file SHA-256 1614a4490202de44ec75c958ade3b79a3c207cc60e712a6be9804f3f01e49d9e = Git working copy.
- Side note: 15:30:05 GET /api/annotations returned 500 after 3.96 s during a dashboard load (memory pressure).
- Discord #devops-alerts (screenshots): 11:42 EDT "[FIRING:1] Root disk space low" Value A=61.343850329350225, C=1, labels device=/dev/vda1 fstype=ext4 mountpoint=/ owner=billy severity=warning, runbook_url present; then "[RESOLVED] Root disk space low" with grafana_state_reason=Updated (resolution came from the restored rule definition; at that moment free space 61.3% > 15%, so the restored condition is false). The summary text is static ("below 15% free") and did not reflect the temporary 70% threshold.
## Controlled incident: Jenkins outage 2026-10-28 (UTC; EDT = UTC-4)
- Pre-check: no Jenkins build process (python3/sh/git/durable) in gitea-jenkins-1; ci probe 1; HTTPS rule instances ci Normal, git Normal. (A first attempt aborted before injection because the check matched the ps header line.)
- 16:05:00 INJECT `cd ~/gitea && docker compose stop jenkins`; container stopped 16:05:06.
- Prometheus ci probe_success samples: 16:04:50 = 1; 16:05:20 = 0 (first failing probe); 0 at 16:05:50, 16:06:20, 16:06:50.
- probe_http_status_code (ci): 200 at 16:04:20, 16:04:50; 502 (Caddy, upstream down) 16:05:20-16:09:50; 0 (no HTTP response while Jenkins was starting) at 16:10:20; 200 at 16:10:50.
- Grafana rule HTTPS service down, instance ci: Normal until ~16:05:48; Pending observed 16:05:54; Alerting observed 16:06:52 (poll every ~6 s). Gitea instance Normal throughout.
- 16:07 (12:07 PM EDT) Discord "[FIRING:1] HTTPS service down SRE https://ci.yebilly.me/login (https billy critical)", Value A=0, C=1, runbook_url present (screenshot).
- Acknowledgement: Billy sent the FIRING screenshot to the operator (Claude session) before the restart; a Discord "ack" reply was posted afterward (its timestamp is later than the restart).
- 16:09:48 RESTART `cd ~/gitea && docker compose start jenkins` (4 min 48 s after injection).
- Jenkins log: 16:10:45.113 "Completed initialization"; 16:10:45.275 "Jenkins is fully up and running".
- ci probe_success: 0 at 16:09:50, 16:10:20; 1 at 16:10:50 (first successful probe). Rule ci instance Alerting until ~16:11:20; Normal observed 16:11:27. Gitea instance Normal throughout.
- (Host-side check with --resolve to 127.0.0.1 returned 403 throughout: the droplet's own loopback request arrives through docker-proxy as the probe gateway 172.30.90.1, which the allowlist denies. Not a service signal.)
- Measured: injection -> first failing sample 20 s; injection -> firing ~1 m 52 s (16:06:52); injection -> Discord ~2 m (16:07); restart -> Jenkins fully up 57 s; restart -> first successful probe sample 62 s; restart -> rule Normal ~1 m 32-39 s; probe-observed outage 16:05:20 -> 16:10:50 (5 m 30 s). Configured worst-case detection = scrape 30 s + evaluation 30 s + pending 60 s + group_wait 10 s = 2 m 10 s; observed ~2 m.
- 16:12 (12:12 PM EDT) Discord "[RESOLVED] HTTPS service down SRE https://ci.yebilly.me/login", Value A=1, C=0 (resolved by evaluation, no state-reason override) (screenshot). Notification receipt -> resolved message ~5 m.
- 16:11:46 laptop: https://ci.yebilly.me/login 200 0.254 s; https://git.yebilly.me/user/login 200 0.050 s.
## Restart persistence 2026-10-28 (UTC)
- Before 16:12:05: oldest TSDB sample 14:52:16; 160 `up{job="prometheus"}` samples in 2 h; dashboard Group 1 SRE v2 (7 panels); data source Prometheus http://prometheus:9090; rules HTTPS service down + Root disk space low (inactive); contact point team-alerts.
- 16:12:09 `docker compose restart prometheus`; answering 16:12:15. After: oldest sample still 14:52:16 (history kept on volume monitoring_prometheus_data). Raw scrapes node 16:11:36, 16:12:06, 16:12:36, 16:13:06; https 16:11:50, 16:12:20, 16:12:50: no gap > 35 s (restart fell between scrapes).
- 16:12:56 `docker compose restart grafana`; at 16:13:44 dashboard v2 7 panels, data source, both rules, contact point all present; admin login unchanged (volume monitoring_grafana_data). A restart shows persistence, not a backup restore.
## SLI short window around the incident (UTC)
- Window [10m] 16:03:00-16:13:00, evaluation time 2026-10-28 16:13:00 UTC, scrape interval 30 s (expected ~20 samples). Queries: 100*avg_over_time(probe_success{job="https",instance="<url>"}[10m]), count_over_time(...), sum_over_time(...).
- Gitea https://git.yebilly.me/user/login: 100% (20 received, 20 successes).
- Jenkins https://ci.yebilly.me/login: 45% (20 received, 9 successes, 11 failures). Raw: 1 at 16:03:20-16:04:50; 0 at 16:05:20-16:10:20; 1 at 16:10:50-16:12:50. No missing samples, so no unknown time; boundary: the first sample in the window is 16:03:20.
- (First attempt evaluated at the wrong epoch, 16:23:00, giving 100%/20 for both; rerun with date -d.)
## Post-recovery verification (UTC)
- Billy pushed b6cf080 (d3a5e6b..b6cf080) after re-authorising Git Credential Manager (stale OAuth refresh token removed).
- Gitea status vpn-dns-gateway/pipeline/head on b6cf080: pending 16:36:27, success 16:37:08 (webhook + status integration working after the outage).
- Jenkins feature/issue-19-monitoring #2: start 16:36:34.6, duration 33.923 s, SUCCESS, "Ran 2 tests ... OK", commit b6cf08061815acd628bf3caaa90e38c46d57a8e7 (slower than #1's 11.8 s, consistent with swap pressure after the restarts).
- Manual PDF build (Gitea Actions, runner latex-local on Vincent's laptop) runs only on pushes to main; it is verified at merge.
## Improvement issues from the blameless review
- #20 "Add an off-droplet uptime check for git, ci, and metrics" (priority 1, owner @vsun1) and #21 "Remove swap churn on The-Ocean (memory headroom)" (priority 2, owner @bill), opened by bill 2026-10-28.
## 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.
## Review gate on PR #22 (UTC)
- PR #22 feature/issue-19-monitoring -> main, opened by Billy.
- Gitea reviews: vsun1 APPROVED 17:09:21 (head b6cf080) and 17:13:53 (head 336eaae); each dismissed as stale when a later commit arrived (branch protection dismisses stale approvals).
- vpn-dns-gateway/pipeline/pr-main: success on 336eaae at 17:12:32; success on 249488d by 17:54:22. Merge still requires a fresh approval of the final head.
- 17:56 live verification: deployed config files byte-identical to Git (9 files, SHA-256); running containers match documented users, memory caps, networks, no host ports except Caddy, no Docker socket, not privileged; image digests match pins; 3 alert rules in grafana.db (for 60 s / 60 s / 300 s, no data -> Alerting, error -> Error); users billy (admin), vsun1; 0 OOM events.
+147
View File
@@ -0,0 +1,147 @@
# Monitoring (Assignment 7 / Instructor Manual Chapter 5)
Prometheus, Grafana OSS, Node Exporter, and Blackbox Exporter on the droplet
**The-Ocean**, beside Gitea, Jenkins, and Caddy (`deploy/`). Grafana is the only
web entry point: `https://metrics.yebilly.me` (same allowlist as Jenkins, then
Grafana login). No monitoring port is published on the host.
| Service | Image (pinned in `compose.yaml`) | Private address | Networks | Memory cap | State |
|---|---|---|---|---|---|
| Prometheus | `prom/prometheus:v3.15.1` | `prometheus:9090` | monitoring | 128 MiB | volume `monitoring_prometheus_data` (7 d / 500 MB) |
| Grafana OSS | `grafana/grafana:13.2.5` | `grafana:3000` | monitoring, `gitea_web` | 192 MiB | volume `monitoring_grafana_data` |
| Node Exporter | `quay.io/prometheus/node-exporter:v1.12.1` | `node-exporter:9100` | monitoring | 32 MiB | none (read-only host `/`) |
| Blackbox Exporter | `quay.io/prometheus/blackbox-exporter:v0.29.1` | `blackbox-exporter:9115`, `172.30.90.10` | monitoring, `gitea_probe` | 32 MiB | none |
Configuration in Git: `prometheus/prometheus.yml`, `blackbox/blackbox.yml`,
`grafana/provisioning/` (data source, dashboard provider, alert rules, contact
point), and `grafana/dashboards/sre.json`. Provisioned items are read-only in
the UI; change them here, copy to the droplet, and restart Grafana.
## Secrets (never in Git)
`~/monitoring/.env.secret` on the droplet, mode `600`, owner root:
```
GF_SECURITY_ADMIN_PASSWORD=<from the team password manager>
DISCORD_WEBHOOK_URL=<webhook for #devops-alerts>
```
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
Prerequisite: `deploy/` is current on the droplet and Caddy has been recreated
once (`cd ~/gitea && docker compose up -d caddy`), which creates the
`gitea_probe` network and the `metrics.yebilly.me` route.
```bash
scp -r monitoring root@<droplet-ip>:~/monitoring # from the laptop
cd ~/monitoring && chmod 700 .
# scp from Windows creates 700 directories; Grafana (uid 472) must read its config.
find grafana prometheus blackbox -type d -exec chmod 755 {} + && find grafana prometheus blackbox -type f -exec chmod 644 {} +
install -m 600 /dev/null .env.secret && nano .env.secret # typed by a team member
docker compose config --quiet
docker compose pull
docker compose run --rm --no-deps --entrypoint /bin/promtool prometheus check config /etc/prometheus/prometheus.yml
docker compose up -d
docker compose ps
docker compose logs --tail=50 prometheus grafana node-exporter blackbox-exporter
docker image inspect --format '{{.RepoDigests}}' prom/prometheus:v3.15.1 # repeat per image
```
Startup order does not matter: Grafana retries the data source and Prometheus
retries scrapes. All four services restart `unless-stopped`.
## Operate, update, back up, roll back
- Pause/resume: `docker compose stop` / `docker compose start`. **Never**
`docker compose down -v`; it deletes both named volumes.
- Config change: edit in Git, copy the file, then
`docker compose restart prometheus` (or `grafana`). Validate Prometheus config
with the `promtool` line above first.
- Upgrade one image at a time: back up, read the release notes, change the tag
and digest in `compose.yaml`, `docker compose pull <svc> && docker compose up -d <svc>`,
then check targets, dashboard, and alert rules. Do not assume an older Grafana
or Prometheus can read data written by a newer one: restore the backup instead.
- Contact-point test (the provisioned contact point has no Test button in the UI;
Grafana 13 removed the old test endpoint). Sends one message to `#devops-alerts`
using the stored URL, which is never printed:
```bash
GIP=$(docker inspect monitoring-grafana-1 --format '{{(index .NetworkSettings.Networks "monitoring_monitoring").IPAddress}}')
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"
unset P # expect {"status":"success",...}; dGVhbS1hbGVydHM is base64 of "team-alerts"
```
- Backup (state not rebuildable from Git: Grafana users/passwords, alert state,
metric history):
```bash
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:3.22 tar czf /b/monitoring-$(date -u +%Y%m%dT%H%M%SZ).tgz /g /p
docker compose start grafana prometheus
```
Restore (same image versions only): `docker compose stop grafana prometheus`,
empty both volumes, then
`docker run --rm -v monitoring_grafana_data:/g -v monitoring_prometheus_data:/p -v /root/backups:/b alpine:3.22 tar xzf /b/monitoring-<stamp>.tgz -C /`
and `docker compose start grafana prometheus`.
- Remove the stack entirely: `docker compose stop && docker compose rm -f`
(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 <service>`.
4. Stopped: `docker compose start <service>`. Running but failing:
`docker compose restart <service>`. 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. 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?
- Both down, and the scrape health panel also shows failures: check Caddy and the droplet first.
- Missing data rather than 0: the monitoring stack itself is failing (`docker compose ps` in `~/monitoring`).
3. On the droplet: `cd ~/gitea && docker compose ps`, then `docker compose logs --tail=50 <gitea|jenkins|caddy>`.
4. If the service container is stopped: `docker compose start <service>`. If it
is running but unhealthy: `docker compose restart <service>`. Never use
`down -v`.
5. Confirm the probe returns to 1 and Discord shows the resolved message. For
Jenkins, also run a pipeline and confirm the Gitea status check.
6. Record the timeline in the incident log or manual.
## Runbook: Root disk space low
Alert `Root disk space low` (warning, owner Billy): available space on `/`
(`/dev/vda1`, ext4) has stayed below 15% for 5 minutes. 15% of 24.9 GB is
about 3.7 GB: enough to act before Gitea, Jenkins, or Prometheus fail to write.
1. Acknowledge in `#devops-alerts`.
2. `df -h /` and `docker system df` to find the growth.
3. Safe first actions: `docker builder prune` (build cache), `journalctl --vacuum-size=200M`,
remove obsolete images with `docker image prune`. Do not delete volumes.
4. Prometheus is capped at 500 MB / 7 days; if it is the cause, lower the cap
rather than deleting its volume.
5. If space cannot be recovered, plan a disk resize (permanent, costs more) with the team.
+14
View File
@@ -0,0 +1,14 @@
# Success = DNS answer, valid certificate for the hostname, redirects followed,
# and a final 2xx on the login page. TLS verification stays on.
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
+97
View File
@@ -0,0 +1,97 @@
# Monitoring stack on The-Ocean (Assignment 7 / Instructor Manual Chapter 5).
# Four project-published images, pinned by tag and digest (the repository ignores
# .env files, so versions live here). No service publishes a host port:
# Caddy reaches grafana:3000 on gitea_web; Prometheus and the exporters stay on
# the private "monitoring" network. Pause with stop/start; never "down -v".
name: monitoring
services:
prometheus:
image: prom/prometheus:v3.15.1@sha256:fa3302279710be2f21a8301ec17a8b4f2301fd829bd113839b3b6b02b6f191a2
restart: unless-stopped
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
- --storage.tsdb.retention.time=7d
- --storage.tsdb.retention.size=500MB # whichever limit is hit first
environment:
- GOMEMLIMIT=96MiB # Go GC target below the container cap
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
networks: [monitoring]
mem_limit: 128m
grafana:
image: grafana/grafana:13.2.5@sha256:9f7aa1e1e3246aade5792d35a738049f7f32f89cd51d1956cf426a4e86268a84
restart: unless-stopped
# Root-only, untracked: GF_SECURITY_ADMIN_PASSWORD and DISCORD_WEBHOOK_URL (see README).
env_file: [.env.secret]
environment:
GF_SERVER_ROOT_URL: https://metrics.yebilly.me/
GF_SECURITY_ADMIN_USER: billy
GF_SECURITY_COOKIE_SECURE: "true"
GF_SECURITY_DISABLE_GRAVATAR: "true"
GF_AUTH_ANONYMOUS_ENABLED: "false"
GF_USERS_ALLOW_SIGN_UP: "false"
GF_METRICS_ENABLED: "false" # no public /metrics through the HTTPS hostname
# 1 GiB droplet: skip plugin downloads, news, and phone-home checks.
GF_PLUGINS_PREINSTALL_DISABLED: "true"
GF_NEWS_NEWS_FEED_ENABLED: "false"
GF_ANALYTICS_REPORTING_ENABLED: "false"
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
GF_ANALYTICS_CHECK_FOR_PLUGIN_UPDATES: "false"
GOMEMLIMIT: 150MiB
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning:ro
- ./grafana/dashboards:/var/lib/grafana-dashboards:ro
networks: [monitoring, web]
mem_limit: 192m
node-exporter:
image: quay.io/prometheus/node-exporter:v1.12.1@sha256:1b4e4438faca4dd7e001dd445d161a4a2091b0fededa84093b3a8dfeae1f1be0
restart: unless-stopped
pid: host
command:
- --path.rootfs=/host
- --path.procfs=/host/proc
- --path.sysfs=/host/sys
# Only what the dashboard and alerts use: CPU, memory, root disk.
- --collector.disable-defaults
- --collector.cpu
- --collector.meminfo
- --collector.filesystem
- --collector.loadavg
- --collector.uname
volumes:
- /:/host:ro,rslave # read-only host view; no Docker socket, not privileged
networks: [monitoring]
mem_limit: 32m
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
networks:
monitoring:
probe:
# The only private address allowed past the ci.yebilly.me allowlist.
ipv4_address: 172.30.90.10
mem_limit: 32m
networks:
monitoring:
web:
external: true
name: gitea_web
probe:
external: true
name: gitea_probe # defined in deploy/docker-compose.yml; Caddy answers git/ci there
volumes:
prometheus_data:
grafana_data:
+578
View File
@@ -0,0 +1,578 @@
{
"uid": "group1-sre",
"title": "Group 1 SRE",
"tags": [
"sre",
"assignment7"
],
"timezone": "America/New_York",
"refresh": "30s",
"time": {
"from": "now-6h",
"to": "now"
},
"schemaVersion": 41,
"version": 1,
"editable": false,
"graphTooltip": 1,
"panels": [
{
"id": 1,
"type": "timeseries",
"title": "Droplet CPU utilization (%)",
"description": "Whole-droplet CPU busy %, averaged across CPUs: 100 minus the idle-time rate over 2m. Counts every workload on the host, not one container. The I/O wait line is the part spent waiting on disk (on this 1 GiB droplet, mostly swap-in), not computation.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 0,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "percent",
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"lineInterpolation": "linear",
"thresholdsStyle": {
"mode": "line"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"min": 0,
"max": 100
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "100 * (1 - avg(rate(node_cpu_seconds_total{job=\"node\",mode=\"idle\"}[2m])))",
"legendFormat": "CPU busy"
},
{
"refId": "B",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "100 * avg(rate(node_cpu_seconds_total{job=\"node\",mode=\"iowait\"}[2m]))",
"legendFormat": "of which I/O wait"
}
]
},
{
"id": 2,
"type": "timeseries",
"title": "Available memory (bytes)",
"description": "MemAvailable: the kernel's estimate of memory available to start new applications without swapping (not just unused RAM).",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 0,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "bytes",
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"lineInterpolation": "linear",
"thresholdsStyle": {
"mode": "line"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "green",
"value": 104857600
}
]
},
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "node_memory_MemAvailable_bytes{job=\"node\"}",
"legendFormat": "available"
}
]
},
{
"id": 3,
"type": "timeseries",
"title": "Root filesystem available (%)",
"description": "Available bytes / size bytes for the host root filesystem (/dev/vda1, ext4, mounted at /). Alert fires below 15% for 5m.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 8,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "percent",
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"lineInterpolation": "linear",
"thresholdsStyle": {
"mode": "line"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "green",
"value": 15
}
]
},
"min": 0,
"max": 100
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "100 * node_filesystem_avail_bytes{job=\"node\",mountpoint=\"/\",fstype=\"ext4\"} / node_filesystem_size_bytes{job=\"node\",mountpoint=\"/\",fstype=\"ext4\"}",
"legendFormat": "/ available"
}
]
},
{
"id": 4,
"type": "timeseries",
"title": "Gitea HTTPS availability (probe_success)",
"description": "1 = Blackbox Exporter fetched the Gitea login page with valid TLS and a 2xx; 0 = the probe failed.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 8,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "none",
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"lineInterpolation": "stepAfter",
"thresholdsStyle": {
"mode": "off"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"min": 0,
"max": 1,
"mappings": [
{
"type": "value",
"options": {
"0": {
"text": "DOWN",
"color": "red"
},
"1": {
"text": "UP",
"color": "green"
}
}
}
]
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "probe_success{job=\"https\",instance=\"https://git.yebilly.me/user/login\"}",
"legendFormat": "Gitea"
}
]
},
{
"id": 5,
"type": "timeseries",
"title": "Jenkins HTTPS availability (probe_success)",
"description": "1 = Blackbox Exporter fetched the Jenkins login page with valid TLS and a 2xx; 0 = the probe failed.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 16,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "none",
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"lineInterpolation": "stepAfter",
"thresholdsStyle": {
"mode": "off"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"min": 0,
"max": 1,
"mappings": [
{
"type": "value",
"options": {
"0": {
"text": "DOWN",
"color": "red"
},
"1": {
"text": "UP",
"color": "green"
}
}
}
]
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "probe_success{job=\"https\",instance=\"https://ci.yebilly.me/login\"}",
"legendFormat": "Jenkins"
}
]
},
{
"id": 6,
"type": "timeseries",
"title": "HTTPS probe duration (s)",
"description": "Total time of each probe (DNS, connect, TLS, request), one line per service.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 16,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "s",
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"lineInterpolation": "linear",
"thresholdsStyle": {
"mode": "off"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "probe_duration_seconds{job=\"https\",instance=\"https://git.yebilly.me/user/login\"}",
"legendFormat": "Gitea"
},
{
"refId": "B",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "probe_duration_seconds{job=\"https\",instance=\"https://ci.yebilly.me/login\"}",
"legendFormat": "Jenkins"
}
]
},
{
"id": 7,
"type": "timeseries",
"title": "Scrape health (up)",
"description": "Optional: 1 = Prometheus scraped the target. For the https job, up=1 can coexist with probe_success=0 (collection worked, the probed request failed).",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 24,
"w": 24,
"h": 6
},
"fieldConfig": {
"defaults": {
"unit": "none",
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"lineInterpolation": "stepAfter",
"thresholdsStyle": {
"mode": "off"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"min": 0,
"max": 1,
"mappings": [
{
"type": "value",
"options": {
"0": {
"text": "DOWN",
"color": "red"
},
"1": {
"text": "UP",
"color": "green"
}
}
}
]
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "up",
"legendFormat": "{{job}} {{instance}}"
}
]
}
],
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
}
}
@@ -0,0 +1,124 @@
# Grafana-managed alerts. Grafana expands $VAR in the contact point, which keeps the
# webhook URL out of Git; templates use .Labels instead of $labels to avoid "$".
apiVersion: 1
contactPoints:
- orgId: 1
name: team-alerts
receivers:
- uid: team-alerts-discord
type: discord
settings:
url: $DISCORD_WEBHOOK_URL # from the untracked .env.secret
disableResolveMessage: false # resolved notifications on
groups:
- orgId: 1
name: sre
folder: SRE
interval: 30s # matches the scrape interval
rules:
- uid: https-service-down
title: HTTPS service down
condition: C
data:
- refId: A
relativeTimeRange: {from: 300, to: 0}
datasourceUid: prometheus
model:
refId: A
expr: probe_success{job="https"}
instant: true
- refId: C
datasourceUid: __expr__
model:
refId: C
type: threshold
expression: A
conditions:
- evaluator: {type: lt, params: [1]}
for: 1m
# A missing series or a failed query is a monitoring failure, not health.
noDataState: Alerting
execErrState: Error
labels: {severity: critical, owner: billy}
annotations:
summary: "{{ .Labels.instance }} HTTPS probe is failing"
description: "probe_success has been 0 for at least 1 minute. Owner: Billy (backup: Vincent)."
runbook_url: https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring/README.md#runbook-https-service-down
notification_settings:
receiver: team-alerts
group_by: [alertname, instance]
group_wait: 10s
group_interval: 1m
repeat_interval: 4h
- uid: root-disk-low
title: Root disk space low
condition: C
data:
- refId: A
relativeTimeRange: {from: 300, to: 0}
datasourceUid: prometheus
model:
refId: A
expr: 100 * node_filesystem_avail_bytes{job="node",mountpoint="/",fstype="ext4"} / node_filesystem_size_bytes{job="node",mountpoint="/",fstype="ext4"}
instant: true
- refId: C
datasourceUid: __expr__
model:
refId: C
type: threshold
expression: A
conditions:
- evaluator: {type: lt, params: [15]}
for: 5m
noDataState: Alerting
execErrState: Error
labels: {severity: warning, owner: billy}
annotations:
summary: "Root filesystem on The-Ocean below 15% free"
description: "Available space on / has stayed under 15% for 5 minutes. Owner: Billy (backup: Vincent)."
runbook_url: https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring/README.md#runbook-root-disk-space-low
notification_settings:
receiver: team-alerts
group_by: [alertname]
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
@@ -0,0 +1,8 @@
apiVersion: 1
providers:
- name: sre
folder: SRE
type: file
allowUiUpdates: false # Git is the source of truth for the dashboard
options:
path: /var/lib/grafana-dashboards
@@ -0,0 +1,11 @@
apiVersion: 1
datasources:
- name: Prometheus
uid: prometheus
type: prometheus
access: proxy
url: http://prometheus:9090 # service name; localhost would be the Grafana container
isDefault: true
editable: false
jsonData:
timeInterval: 30s
+30
View File
@@ -0,0 +1,30 @@
global:
scrape_interval: 30s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ["prometheus:9090"]
- job_name: node
static_configs:
- targets: ["node-exporter:9100"]
- job_name: blackbox
static_configs:
- targets: ["blackbox-exporter:9115"]
# Multi-target pattern: each URL becomes the probe target and the instance label;
# the scrape itself goes to Blackbox Exporter's /probe endpoint.
- job_name: https
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets:
- https://git.yebilly.me/user/login
- https://ci.yebilly.me/login
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: blackbox-exporter:9115