1501 lines
76 KiB
TeX
1501 lines
76 KiB
TeX
\chapter{Introduction to SRE: Monitoring and Reliability}
|
|
\ChapterLabel{SRE}
|
|
\index{site reliability engineering}
|
|
\index{Prometheus}
|
|
\index{Grafana}
|
|
\sloppy
|
|
|
|
% Figure helper: shows a labelled box until the screenshot file exists.
|
|
\providecommand{\srefig}[4]{%
|
|
\begin{figure}[H]\centering
|
|
\IfFileExists{HW7 images/#1}{\includegraphics[width=#2\linewidth]{HW7 images/#1}}%
|
|
{\fbox{\parbox{0.8\linewidth}{\centering\vspace{1em}\textit{[Screenshot needed: HW7 images/#1]}\vspace{1em}}}}
|
|
\caption{#3}\label{#4}\end{figure}}
|
|
|
|
\section{Deployment and Reproducibility}
|
|
\label{sec:sre-deploy}
|
|
|
|
\begin{description}
|
|
\item[Issue:] \#18,
|
|
\url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/issues/18}.
|
|
Implementation owner \texttt{samahk13}, verifier \texttt{kholmes}.
|
|
\item[Branch:] \texttt{feature/issue-18-monitoring}; first commit
|
|
\texttt{4c09870} (``Add monitoring stack config for \#18'')
|
|
\item[Starting commit:] \texttt{main} at
|
|
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/commit/3301e2463ee32d4688330182a41f8ffddcdaed46}{\texttt{3301e2463ee32d4688330182a41f8ffddcdaed46}},
|
|
the merge of pull request \#17
|
|
\item[Passing builds at the start:] Jenkins \texttt{Scrap-Web/main} run \#5
|
|
(October 28, 2026, 3:28 PM EDT) and run \#6 (3:44:57 PM EDT), both
|
|
\emph{SUCCESS} on \texttt{3301e24}
|
|
\item[Configuration:] the \texttt{monitoring/} directory of Scrap-Web,
|
|
deployed on the Droplet at \texttt{/root/Scrap-Web/monitoring}
|
|
\end{description}
|
|
|
|
\subsection{Baseline}
|
|
The baseline was recorded on October 28, 2026, at 3:22 PM EDT, before any
|
|
monitoring container was started:
|
|
|
|
\begin{tabularx}{\linewidth}{L{3.6cm}Y}
|
|
\toprule
|
|
\textbf{Item} & \textbf{Value}\\ \midrule
|
|
Operating system & Ubuntu 24.04.5 LTS, kernel 6.8.0-147-generic, x86\_64\\
|
|
CPU & 1 vCPU (DO-Regular); load average 0.21, 0.17, 0.11\\
|
|
Memory & 2{,}063{,}568{,}896 bytes total; 791{,}658{,}496 bytes available; no swap\\
|
|
Root filesystem & \texttt{/dev/vda1} at \texttt{/}: 50{,}884{,}108{,}288 bytes,
|
|
45{,}612{,}322{,}816 bytes available (11\% used)\\
|
|
Docker & Engine 29.8.2; Compose v5.5.1\\
|
|
Running services & \texttt{jenkins} (\texttt{custom-jenkins:lts-jdk21-python3},
|
|
695.8 MiB), \texttt{gitea} (\texttt{gitea/gitea:1.26.4}, 218.1 MiB),
|
|
\texttt{caddy} (\texttt{caddy:2}, 26.7 MiB)\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
\textbf{Capacity change before deployment.} The Droplet had about 775 MB of
|
|
available memory and no swap. If Jenkins and the four new containers reached
|
|
their peak memory use at the same time, the kernel could terminate a
|
|
container. A 1~GB swap file was therefore added before deployment and made
|
|
persistent in \texttt{/etc/fstab}:
|
|
\begin{minted}[breaklines,breakanywhere]{bash}
|
|
fallocate -l 1G /swapfile && chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile
|
|
echo '/swapfile none swap sw 0 0' >> /etc/fstab
|
|
free -h # Swap: 1.0Gi total, 0B used
|
|
\end{minted}
|
|
Rollback: \texttt{swapoff /swapfile}, remove the \texttt{fstab} line, and
|
|
delete \texttt{/swapfile}.
|
|
|
|
\textbf{Capacity, headroom, and retention rationale.} Each resource was judged
|
|
against the baseline above and the build observations in
|
|
Section~\ref{sec:sre-dashboard}.
|
|
\begin{itemize}
|
|
\item \textbf{CPU} (1 vCPU, load average 0.21 at baseline). A normal Jenkins
|
|
build was a CPU burst of under 10 seconds, after which every container fell
|
|
back below 1\% (run \#6). Scraping five targets every 30 seconds is short,
|
|
periodic work, so CPU was not expected to limit the stack. The monitoring
|
|
stack's own CPU cost was not measured separately.
|
|
\item \textbf{Memory} is the tightest resource. About 791.7~MB of 2.06~GB
|
|
(38\%) was available at baseline with no swap, and Jenkins alone used
|
|
695.8~MiB. The four monitoring containers add to that, which is why the
|
|
1~GB swap file was added first. A normal build changed available memory by
|
|
only about 10~MB, so build activity does not threaten the margin.
|
|
\item \textbf{Disk.} 45.6~GB of 50.9~GB (about 90\%) was free at baseline.
|
|
By October 30 the root filesystem was 18.2\% used, still above the 15\%
|
|
free-space alert threshold with a wide margin
|
|
(Figure~\ref{fig:sre-disk-usage}). The rise from 11\% is consistent with the
|
|
swap file, four images, and Prometheus data, but it was not broken down by
|
|
cause.
|
|
\item \textbf{Retention} is 7 days or 5~GiB, whichever is reached first. Seven
|
|
days is the assignment's suggested lab starting point, and it is long
|
|
enough to cover the exercise window, the restart test, and a few days of
|
|
history. The 5~GiB cap is about 12\% of the free space at baseline, so it
|
|
leaves roughly 37~GiB for the operating system, images, Jenkins and Gitea
|
|
data, and builds. The cap is a ceiling that stops the database from filling
|
|
the disk and triggering the capacity alert on its own. It is not an
|
|
estimate of actual use, and the database size was not measured here.
|
|
\end{itemize}
|
|
Conclusion: the Droplet has headroom for monitoring, builds, and service data,
|
|
with memory as the limiting factor.
|
|
|
|
\subsection{Selected Versions and Image Digests}
|
|
All four images come from the repositories published by the projects~\cite{PrometheusDocs,GrafanaDocs,NodeExporter,BlackboxExporter}. Each tag
|
|
was chosen as a current supported release and pinned in
|
|
\texttt{monitoring/.env}; no \texttt{latest} tag is used. The digests were
|
|
recorded with \texttt{docker image inspect IMAGE:TAG --format
|
|
'\{\{index .RepoDigests 0\}\}'} after \texttt{docker compose pull} on
|
|
October 28, 2026.
|
|
|
|
\begin{tabularx}{\linewidth}{L{2.6cm}L{4.4cm}Y}
|
|
\toprule
|
|
\textbf{Component} & \textbf{Image and tag} & \textbf{Digest (sha256)}\\ \midrule
|
|
Prometheus & \nolinkurl{prom/prometheus:v3.13.5} (LTS) &
|
|
\texttt{\seqsplit{aafa9d694e6a883c02db516d9f6e5b84e14195f49a2a6456a4cca815edda72b9}}\\
|
|
Grafana OSS & \nolinkurl{grafana/grafana:13.2.5} &
|
|
\texttt{\seqsplit{9f7aa1e1e3246aade5792d35a738049f7f32f89cd51d1956cf426a4e86268a84}}\\
|
|
Node Exporter & \nolinkurl{quay.io/prometheus/node-exporter:v1.12.1} &
|
|
\texttt{\seqsplit{1b4e4438faca4dd7e001dd445d161a4a2091b0fededa84093b3a8dfeae1f1be0}}\\
|
|
Blackbox Exporter & \nolinkurl{quay.io/prometheus/blackbox-exporter:v0.29.0} &
|
|
\texttt{\seqsplit{9613f2884689b6fad9f1939f6a3b0388c93a022cfaededb19545b329b5c83dea}}\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
All four images are \texttt{linux/amd64}, matching the Droplet. Existing
|
|
services were not upgraded.
|
|
|
|
\subsection{Deployment Diagram}
|
|
Figure~\ref{fig:sre-deployment} shows the deployment as defined by
|
|
\texttt{monitoring/compose.yaml}. Arrows point from the side that starts the
|
|
request.
|
|
|
|
\begin{figure}[H]
|
|
\centering
|
|
\includegraphics[width=\linewidth]{figures/sre-deployment.png}
|
|
\caption{Gitea, Jenkins, and the four monitoring containers on the Droplet.
|
|
Grafana is attached to both Docker networks: \texttt{gitea-net}, so Caddy
|
|
can reach \texttt{grafana:3000}, and \texttt{monitoring}, so it can query
|
|
Prometheus. Prometheus and both exporters are on the \texttt{monitoring}
|
|
network only and publish no host port. Because Blackbox Exporter is not on
|
|
\texttt{gitea-net}, its probes reach Caddy through the public hostnames.
|
|
The named volumes keep Prometheus and Grafana state; Jenkins state is in
|
|
\texttt{jenkins\_home}. Gitea's data volume is not shown.}
|
|
\label{fig:sre-deployment}
|
|
\end{figure}
|
|
|
|
\subsection{Compose Configuration}
|
|
The stack is defined in \texttt{monitoring/compose.yaml}
|
|
(\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/monitoring/compose.yaml}{in
|
|
Gitea}). Unlike the assignment's reference, Grafana publishes no host port. The
|
|
existing Caddy reverse proxy runs in a container on the \texttt{gitea-net}
|
|
network, so Grafana joins that network and Caddy reaches it as
|
|
\texttt{grafana:3000}. Prometheus and both exporters stay on the private
|
|
\texttt{monitoring} network only.
|
|
|
|
\begin{minted}[fontsize=\footnotesize,breaklines,breakanywhere]{yaml}
|
|
services:
|
|
prometheus:
|
|
image: prom/prometheus:${PROMETHEUS_TAG:?choose a release}
|
|
container_name: prometheus
|
|
restart: unless-stopped
|
|
command:
|
|
- --config.file=/etc/prometheus/prometheus.yml
|
|
- --storage.tsdb.path=/prometheus
|
|
- --storage.tsdb.retention.time=7d
|
|
- --storage.tsdb.retention.size=5GB
|
|
volumes:
|
|
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
|
- prometheus_data:/prometheus
|
|
networks: [monitoring]
|
|
grafana:
|
|
image: grafana/grafana:${GRAFANA_TAG:?choose a release}
|
|
container_name: grafana
|
|
restart: unless-stopped
|
|
depends_on: [prometheus]
|
|
env_file: [grafana.secrets.env] # admin password; not in Git
|
|
environment:
|
|
GF_SERVER_ROOT_URL: "https://metrics.ssw590-08.me/"
|
|
GF_SERVER_DOMAIN: "metrics.ssw590-08.me"
|
|
GF_AUTH_ANONYMOUS_ENABLED: "false"
|
|
GF_USERS_ALLOW_SIGN_UP: "false"
|
|
GF_DATE_FORMATS_DEFAULT_TIMEZONE: "America/New_York"
|
|
volumes:
|
|
- grafana_data:/var/lib/grafana
|
|
- ./grafana/provisioning:/etc/grafana/provisioning:ro
|
|
- ./grafana/dashboards:/var/lib/grafana/dashboards:ro
|
|
networks: [monitoring, gitea-net]
|
|
node-exporter:
|
|
image: quay.io/prometheus/node-exporter:${NODE_EXPORTER_TAG:?choose a release}
|
|
container_name: node-exporter
|
|
restart: unless-stopped
|
|
pid: host
|
|
command: [--path.rootfs=/host, --path.procfs=/host/proc, --path.sysfs=/host/sys]
|
|
volumes:
|
|
- /:/host:ro,rslave
|
|
networks: [monitoring]
|
|
blackbox-exporter:
|
|
image: quay.io/prometheus/blackbox-exporter:${BLACKBOX_TAG:?choose a release}
|
|
container_name: blackbox-exporter
|
|
restart: unless-stopped
|
|
command: ["--config.file=/config/blackbox.yml"]
|
|
volumes:
|
|
- ./blackbox/blackbox.yml:/config/blackbox.yml:ro
|
|
networks: [monitoring]
|
|
networks:
|
|
monitoring:
|
|
gitea-net: {external: true, name: gitea-net}
|
|
volumes:
|
|
prometheus_data:
|
|
grafana_data:
|
|
\end{minted}
|
|
|
|
\begin{tabularx}{\linewidth}{L{5.2cm}Y}
|
|
\toprule
|
|
\textbf{File} & \textbf{Purpose}\\ \midrule
|
|
\nolinkurl{.env} & Pinned image tags only (no secrets)\\
|
|
\nolinkurl{prometheus/prometheus.yml} & Scrape jobs \texttt{prometheus}, \texttt{node},
|
|
\texttt{blackbox}, and \texttt{https} (Section~\ref{sec:sre-metrics})\\
|
|
\nolinkurl{blackbox/blackbox.yml} & \texttt{http\_2xx} probe module\\
|
|
\nolinkurl{grafana/provisioning/datasources/prometheus.yml} & Data source
|
|
\texttt{Prometheus}, \texttt{http://prometheus:9090}, uid \texttt{prometheus}\\
|
|
\nolinkurl{grafana/provisioning/dashboards/dashboards.yml} & Loads dashboards from
|
|
\texttt{grafana/dashboards/} into folder ``SSW 590''\\
|
|
\nolinkurl{grafana/dashboards/ssw590-sre.json} & Team dashboard
|
|
(Section~\ref{sec:sre-dashboard})\\
|
|
\nolinkurl{grafana/alerting/alert-rules.yaml} & Sanitized export of the alert
|
|
rules (Section~\ref{sec:sre-alerts})\\
|
|
\nolinkurl{RUNBOOK.md} & Alert response procedures linked from each rule\\
|
|
\nolinkurl{grafana.secrets.env.example} & Template for the secrets file; the real
|
|
\texttt{grafana.secrets.env} is listed in \texttt{.gitignore}\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\subsection{Identities, Mounts, and Persistent Storage}
|
|
\begin{itemize}
|
|
\item Every container runs as its image's default user. None is
|
|
\texttt{privileged}, and none mounts the Docker socket.
|
|
\item Configuration files are mounted read-only (\texttt{:ro}).
|
|
\item \textbf{Prometheus} stores its time-series database in the named volume
|
|
\texttt{monitoring\_\allowbreak prometheus\_\allowbreak data}, mounted at \texttt{/prometheus}.
|
|
Retention is 7 days or 5~GB, whichever is reached first. The log confirmed
|
|
\texttt{TSDB retention updated duration=1w size=5GiB}.
|
|
\item \textbf{Grafana} stores users, sessions, alert state, and the contact
|
|
point in the named volume \texttt{monitoring\_\allowbreak grafana\_\allowbreak data}, mounted at
|
|
\texttt{/var/lib/grafana}. The data source and dashboard come from
|
|
provisioned files in Git; the alert rules are kept as a versioned export.
|
|
\item On the host, both volumes live under
|
|
\texttt{/var/lib/docker/volumes/<name>/\_data}, owned by root.
|
|
\item \textbf{Node Exporter} needs read-only access to the host root
|
|
filesystem (\texttt{/:/host:ro,rslave}) and the host PID namespace
|
|
(\texttt{pid: host}). Without them it cannot report host CPU, memory, and
|
|
root-filesystem values. It uses the bridge network, so its network-interface
|
|
metrics do not describe all host interfaces.
|
|
\item All four services use \texttt{restart: unless-stopped}.
|
|
\texttt{depends\_on} starts Prometheus before Grafana; the exporters have no
|
|
start-order requirement.
|
|
\end{itemize}
|
|
|
|
\subsection{Validation and Startup}
|
|
From \texttt{/root/Scrap-Web/monitoring} on October 28, 2026:
|
|
\begin{minted}[breaklines,breakanywhere]{bash}
|
|
docker compose config --quiet # no output: Compose file is valid
|
|
docker compose pull # all four images pulled
|
|
docker compose run --rm --no-deps --entrypoint /bin/promtool \
|
|
prometheus check config /etc/prometheus/prometheus.yml
|
|
# SUCCESS: /etc/prometheus/prometheus.yml is valid prometheus config file syntax
|
|
docker compose up -d # 2 volumes created, 4 containers started
|
|
docker compose ps # all four "Up"; ports 9090/9100/9115/3000 internal only
|
|
docker compose logs --tail=50 prometheus grafana node-exporter blackbox-exporter
|
|
docker compose images
|
|
\end{minted}
|
|
The logs showed Prometheus 3.13.5 \emph{``Server is ready to receive web
|
|
requests''}, Node Exporter and Blackbox Exporter 0.29.0 listening on 9100 and
|
|
9115, and Grafana completing its database migrations. The \texttt{PORTS}
|
|
column lists only container ports; no host port is published.
|
|
|
|
\srefig{sre-targets-up.png}{1.0}{October 28, 2026, 5:10:20 PM EDT --- Grafana
|
|
Explore instant queries after the first start: \texttt{up} is 1 for all five
|
|
scrape targets, and \texttt{probe\_success} is 1 for both HTTPS
|
|
URLs.}{fig:sre-targets-up}
|
|
|
|
\subsection{Routine Operation, Update, and Recovery}
|
|
\begin{tabularx}{\linewidth}{L{3.2cm}Y}
|
|
\toprule
|
|
\textbf{Task} & \textbf{Procedure}\\ \midrule
|
|
Pause / resume & \texttt{docker compose stop} / \texttt{docker compose start}.
|
|
Never use \texttt{docker compose down -v}, which deletes both named volumes.\\
|
|
Configuration change & Edit the file in Git, \texttt{git pull} on the Droplet,
|
|
validate (\texttt{docker compose config --quiet}; \texttt{promtool check
|
|
config}), then \texttt{docker compose restart prometheus} (or the affected
|
|
service).\\
|
|
Upgrade one component & Back up its volume (below), read the release notes,
|
|
change one tag in \texttt{.env}, then run \texttt{docker compose pull SERVICE}
|
|
and \texttt{docker compose up -d SERVICE}. Check health and history, record
|
|
the new digest, and commit.\\
|
|
Rollback & Restore the previous tag in \texttt{.env} and recreate the service.
|
|
If the newer version migrated its data (Grafana's database, Prometheus'
|
|
TSDB), restore the pre-upgrade volume backup as well, because an older version
|
|
may not read upgraded data.\\
|
|
Recover the whole stack & \texttt{git clone} Scrap-Web, recreate
|
|
\texttt{grafana.secrets.env} from the example, restore the volume backups if
|
|
available, then run \texttt{docker compose up -d}. The data source and
|
|
dashboard are re-provisioned from Git. Alert rules are re-imported from
|
|
\texttt{alert-rules.yaml}, and the Discord contact point is re-created with
|
|
the webhook kept outside Git.\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
\textbf{Backup of state that Git cannot rebuild} (Grafana users, alert state,
|
|
contact point; Prometheus history):
|
|
\begin{minted}[breaklines,breakanywhere]{bash}
|
|
cd /root/Scrap-Web/monitoring && docker compose stop grafana prometheus
|
|
for v in monitoring_grafana_data monitoring_prometheus_data; do
|
|
docker run --rm -v $v:/data:ro -v /root/backups:/backup alpine \
|
|
tar czf /backup/$v-$(date +%F).tgz -C /data .
|
|
done
|
|
docker compose start prometheus grafana
|
|
\end{minted}
|
|
The archives contain the Grafana database, so they are kept on the Droplet
|
|
under \texttt{/root/backups} (root only) and are never committed to Git.
|
|
|
|
\subsection{Restart Persistence Test}
|
|
Prometheus and Grafana were restarted separately on October 29, 2026, without
|
|
removing any volume:
|
|
\begin{minted}[breaklines,breakanywhere]{bash}
|
|
cd /root/Scrap-Web/monitoring
|
|
date -Is; docker compose restart prometheus # 2026-10-29T22:18:29+00:00 (6:18:29 PM EDT)
|
|
sleep 90
|
|
date -Is; docker compose restart grafana # 2026-10-29T22:21:59+00:00 (6:21:59 PM EDT)
|
|
\end{minted}
|
|
|
|
After both restarts, the dashboard opened at
|
|
\url{https://metrics.ssw590-08.me/} without being re-created
|
|
(Figure~\ref{fig:sre-dashboard-full}, captured about 6:35 PM EDT).
|
|
\begin{itemize}
|
|
\item With the range set to the last 2 days, every panel still shows the
|
|
history that starts when the stack was first deployed on October 28 at about
|
|
4 PM, including the Jenkins outage at 4:09--4:13 PM on October 29.
|
|
\item The Prometheus data source returned data, so its provisioned definition
|
|
survived.
|
|
\item The dashboard itself survived, because it is provisioned from Git.
|
|
\end{itemize}
|
|
While Prometheus restarted, at most one or two 30-second scrapes could be
|
|
missed. Such a gap is not visible at a 2-day scale, and those samples are
|
|
treated as missing, not as successes. While Grafana restarted, the dashboard and
|
|
alert evaluation were briefly unavailable; Prometheus kept collecting
|
|
throughout. This test demonstrates that data persists across container
|
|
restarts. It is not a test of restoring from a backup.
|
|
% >>> optional: screenshot of Alerting -> Alert rules after the restart <<<
|
|
\section{Metrics and Probes}
|
|
\label{sec:sre-metrics}
|
|
|
|
\subsection{Scrape and Probe Configuration}
|
|
Prometheus collects metrics every 30 seconds through four jobs. Every target is
|
|
reached by Docker service name on the private \texttt{monitoring} network; none
|
|
is published on the host (Section~\ref{sec:sre-deploy}).
|
|
|
|
\begin{tabularx}{\linewidth}{L{2.2cm}L{4.4cm}Y}
|
|
\toprule
|
|
\textbf{Job} & \textbf{Target} & \textbf{Collects}\\ \midrule
|
|
\texttt{prometheus} & \texttt{prometheus:9090} & Prometheus' own metrics\\
|
|
\texttt{node} & \texttt{node-exporter:9100} & Whole-Droplet CPU, memory, and
|
|
root-filesystem space\\
|
|
\texttt{blackbox} & \texttt{blackbox-exporter:9115} & Blackbox Exporter's own
|
|
\texttt{/metrics}\\
|
|
\texttt{https} & \nolinkurl{https://git.ssw590-08.me/user/login} and
|
|
\nolinkurl{https://ci.ssw590-08.me/login}, scraped through
|
|
\texttt{blackbox-exporter:9115/probe} with module \texttt{http\_2xx} &
|
|
\texttt{probe\_success} and \texttt{probe\_duration\_seconds} for each
|
|
URL\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
The \texttt{https} job uses the multi-target pattern: each URL is passed to
|
|
Blackbox Exporter as the probe target, kept as the \texttt{instance} label, and
|
|
the scrape itself is sent to the exporter's \texttt{/probe} endpoint. This is why
|
|
the queries in this chapter select a service with
|
|
\texttt{job="https",instance="<URL>"}. The probe interface stays private, and
|
|
the \texttt{blackbox} job scrapes the exporter's own \texttt{/metrics} as a
|
|
separate job.
|
|
|
|
The deployed \texttt{monitoring/blackbox/blackbox.yml} defines one module:
|
|
\begin{minted}[fontsize=\footnotesize]{yaml}
|
|
modules:
|
|
http_2xx:
|
|
prober: http
|
|
timeout: 10s
|
|
http:
|
|
method: GET
|
|
preferred_ip_protocol: ip4
|
|
valid_status_codes: [] # empty = any 2xx is success
|
|
follow_redirects: true
|
|
fail_if_not_ssl: true
|
|
tls_config:
|
|
insecure_skip_verify: false
|
|
\end{minted}
|
|
|
|
The deployed \texttt{monitoring/prometheus/prometheus.yml}:
|
|
\begin{minted}[fontsize=\footnotesize]{yaml}
|
|
global:
|
|
scrape_interval: 30s
|
|
evaluation_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"]
|
|
|
|
- job_name: https
|
|
metrics_path: /probe
|
|
params:
|
|
module: [http_2xx]
|
|
static_configs:
|
|
- targets:
|
|
- https://git.ssw590-08.me/user/login
|
|
- https://ci.ssw590-08.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 \texttt{relabel\_configs} copy each target URL into the \texttt{target}
|
|
parameter and the \texttt{instance} label, then send the request to the
|
|
Blackbox Exporter's address.
|
|
|
|
\subsection{Target Health}
|
|
Figure~\ref{fig:sre-targets-up} shows the state after the first start:
|
|
\texttt{up} is 1 for all five scrape targets (the \texttt{prometheus},
|
|
\texttt{node}, and \texttt{blackbox} jobs and the two probe URLs), and
|
|
\texttt{probe\_success} is 1 for both HTTPS URLs. \texttt{up} and
|
|
\texttt{probe\_success} answer different questions. \texttt{up} says that
|
|
Prometheus collected a result from the target. \texttt{probe\_success} says
|
|
whether the probed request itself succeeded, so \texttt{up} can be 1 while a
|
|
service is down. The dashboard keeps a separate scrape-health row for this
|
|
reason (Section~\ref{sec:sre-dashboard}).
|
|
|
|
\subsection{Metric Inventory}
|
|
The metrics behind the dashboard and the alerts:
|
|
|
|
\begin{tabularx}{\linewidth}{L{3.5cm}L{3.1cm}YY}
|
|
\toprule
|
|
\textbf{Metric (type, unit)} & \textbf{Labels used} & \textbf{Meaning} &
|
|
\textbf{Limitation}\\ \midrule
|
|
\texttt{node\_cpu\_\allowbreak seconds\_total} (counter, seconds) & \texttt{cpu},
|
|
\texttt{mode} & Cumulative CPU time per mode; utilization is derived from the
|
|
rate of the idle mode & A lifetime total, so only its rate is meaningful.
|
|
Whole Droplet (1~vCPU), not per container\\
|
|
\texttt{node\_memory\_\allowbreak MemAvailable\_bytes} (gauge, bytes) &
|
|
\texttt{job}, \texttt{instance} & Kernel estimate of memory available to new
|
|
programs without swapping & Not the same as unused RAM; no per-container
|
|
split\\
|
|
\texttt{node\_filesystem\_\allowbreak avail\_bytes} and
|
|
\texttt{node\_filesystem\_\allowbreak size\_bytes} (gauges, bytes) &
|
|
\texttt{device}, \texttt{fstype}, \texttt{mountpoint} (values \texttt{/dev/vda1},
|
|
\texttt{ext4}, \texttt{/}) &
|
|
Space available and total size of the root filesystem; their ratio is the
|
|
percentage available & The selector must name this one filesystem so overlay
|
|
and pseudo filesystems are excluded\\
|
|
\texttt{up} (gauge, 0/1) & \texttt{job}, \texttt{instance} & 1 if the last
|
|
scrape of the target succeeded & Collection health only; says nothing about
|
|
whether a measurement is correct or a service works\\
|
|
\texttt{probe\_success} (gauge, 0/1) & \texttt{job="https"}, \texttt{instance}
|
|
(the URL) & 1 if the probe met its success criteria & Login page only, probed
|
|
from the Droplet\\
|
|
\texttt{probe\_duration\_\allowbreak seconds} (gauge, seconds) & same as
|
|
\texttt{probe\_success} & Total probe time, including DNS, connection, TLS,
|
|
and the request & One vantage point; a single slow sample is not a trend\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
The exported root-filesystem labels were checked rather than assumed. With the
|
|
host root mounted at \texttt{/host} inside the Node Exporter container, the
|
|
series for the host root still carries \texttt{mountpoint="/"},
|
|
\texttt{device="/dev/vda1"}, and \texttt{fstype="ext4"}
|
|
(Figure~\ref{fig:sre-disk-normal}), and the alert and dashboard selectors use
|
|
exactly these labels.
|
|
|
|
\subsection{Host Metric Verification}
|
|
Node Exporter was compared with the operating system on the Droplet at
|
|
8:02:50 PM EDT (2026-10-31T00:02:50Z) on October 30, 2026. The Prometheus values were
|
|
read from the Prometheus HTTP API inside its container, within a second of the
|
|
operating-system commands.
|
|
|
|
\begin{tabularx}{\linewidth}{L{3.2cm}L{3.3cm}L{3.3cm}Y}
|
|
\toprule
|
|
\textbf{Quantity} & \textbf{Prometheus (bytes)} & \textbf{Operating system (bytes)} & \textbf{Difference}\\ \midrule
|
|
Memory available & 723,578,880 & 733,319,168 (\texttt{free -b}) & 9.7~MB (1.3\%)\\
|
|
Root filesystem size & 50,884,108,288 & 50,884,108,288 (\texttt{df -B1 /}) & none\\
|
|
Root filesystem available & 41,571,614,720 & 41,571,602,432 (\texttt{df -B1 /}) & 12,288 bytes\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
\begin{itemize}
|
|
\item The filesystem size matches exactly. Available space differs by 12,288
|
|
bytes, which is ordinary change on a live disk between two reads less than a
|
|
second apart. Both give about 81.7\% available, and \texttt{df} reports 19\%
|
|
used.
|
|
\item Available memory differs by about 1.3\%. The two reads are not
|
|
simultaneous and the value changes continuously, so a small difference is
|
|
expected. \texttt{top} reported 699.8~MiB (about 733.8~MB) available, which
|
|
agrees with \texttt{free}.
|
|
\item CPU idle was compared at 8:23:25--28 PM EDT (00:23:25--28 UTC). The second
|
|
\texttt{top} sample, taken over a 5-second interval, showed 86.8\% idle
|
|
(with 4.3\% steal time). Prometheus returned 90.2\% for
|
|
\texttt{100 * avg(rate(node\_cpu\_seconds\_total\{mode="idle"\}[2m]))}. The
|
|
3.4-point difference is expected, because \texttt{top} measures 5 seconds and
|
|
the query averages 2 minutes. Both show a mostly idle host, but this is a
|
|
single comparison, not an exact match.
|
|
\end{itemize}
|
|
|
|
\subsection{Probe Success Criteria}
|
|
A probe succeeds only if Blackbox Exporter's \texttt{http\_2xx} module completes
|
|
the whole request: DNS resolution, the TCP connection, a TLS handshake with
|
|
certificate and hostname verification, and a final HTTP 2xx response after any
|
|
redirects. TLS verification is not disabled. The probed URLs are the login pages
|
|
\nolinkurl{https://git.ssw590-08.me/user/login} and
|
|
\nolinkurl{https://ci.ssw590-08.me/login}.
|
|
The module has a 10-second timeout and prefers IPv4. It sets
|
|
\texttt{fail\_if\_not\_ssl: true}, so a plain-HTTP response fails, and
|
|
\texttt{insecure\_skip\_verify: false}, so an invalid certificate fails.
|
|
Because \texttt{valid\_status\_codes} is empty, any 2xx status counts as success.
|
|
The module has no body-match setting: the check is the login page's response
|
|
status, not its content.
|
|
|
|
\subsection{Limitations}
|
|
\begin{itemize}
|
|
\item The host metrics describe the whole Droplet. They cannot attribute CPU
|
|
or memory to Jenkins, Gitea, or any one container.
|
|
\item Node Exporter runs on the bridge network, so its network-interface
|
|
metrics do not describe all host interfaces. They are not used.
|
|
\item A 30-second scrape can miss anything shorter, such as the 5-second build
|
|
in Section~\ref{sec:sre-dashboard}.
|
|
\item A successful login-page probe does not prove that authenticated Git
|
|
operations or builds work.
|
|
\item Probes run from the Droplet, so they do not prove reachability from
|
|
users' networks. Monitoring shares the Droplet's failure domain
|
|
(Section~\ref{sec:sre-incident}).
|
|
\item An exporter being reachable does not establish that its measurements are
|
|
correct, which is why the host values are compared with the operating
|
|
system above.
|
|
\end{itemize}
|
|
\section{HTTPS and Access Control}
|
|
\label{sec:sre-access}
|
|
|
|
\subsection{HTTPS Login URLs}
|
|
\begin{tabularx}{\linewidth}{L{2.4cm}L{6.2cm}Y}
|
|
\toprule
|
|
\textbf{Service} & \textbf{Login URL} & \textbf{Route}\\ \midrule
|
|
Gitea & \url{https://git.ssw590-08.me/user/login} & Caddy $\rightarrow$
|
|
\texttt{gitea:3000}\\
|
|
Jenkins & \url{https://ci.ssw590-08.me/login} & Caddy $\rightarrow$
|
|
\texttt{jenkins:8080}\\
|
|
Grafana & \url{https://metrics.ssw590-08.me/login} & Caddy $\rightarrow$
|
|
\texttt{grafana:3000}\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
Gitea and Jenkins keep the HTTPS routing, certificates, and firewall rules from
|
|
the earlier chapters (Section~\ref{sec:ci-https}). Grafana was added behind the
|
|
same Caddy proxy on its own hostname. Caddy and Grafana share the
|
|
\texttt{gitea-net} Docker network, so the route needs no host port.
|
|
|
|
\subsection{Access Instructions}
|
|
No password is written in this report.
|
|
\begin{enumerate}
|
|
\item Open the Grafana URL above. Anonymous access is disabled, so the page
|
|
redirects to the login form.
|
|
\item Sign in with a named Grafana account. The administrator password is
|
|
supplied from \texttt{grafana.secrets.env} on the Droplet, which is listed in
|
|
\texttt{.gitignore} and is not in Git. The hint is in the Passwords table
|
|
(Table~\ref{tab:devops-passwords}).
|
|
\item Open the dashboard at \url{https://metrics.ssw590-08.me/d/ssw590-sre}.
|
|
\end{enumerate}
|
|
No grader account was created. The dashboard, alert rules, notifications, and
|
|
incident evidence needed for grading are embedded as figures in this chapter.
|
|
|
|
\subsection{Authentication and Secret Handling}
|
|
\begin{itemize}
|
|
\item Grafana has anonymous access and self-registration turned off
|
|
(\texttt{GF\_AUTH\_ANONYMOUS\_ENABLED=false},
|
|
\texttt{GF\_USERS\_ALLOW\_SIGN\_UP=false}), so only accounts created by an
|
|
administrator can sign in.
|
|
\item The Discord webhook URL is stored only in Grafana's database and never
|
|
in Git or screenshots. The abandoned Gmail app password was revoked
|
|
(Section~\ref{sec:sre-alerts}).
|
|
\item No monitoring container is \texttt{privileged}, and none mounts the
|
|
Docker socket. Node Exporter's read-only host mount and host PID namespace
|
|
are the only host access, and Section~\ref{sec:sre-deploy} explains why they
|
|
are needed.
|
|
\end{itemize}
|
|
|
|
\subsection{Proxy and Port Exposure}
|
|
Only Caddy publishes web ports on the Droplet (80 and 443). The Compose file
|
|
publishes no port for Grafana, Prometheus, Node Exporter, or Blackbox Exporter,
|
|
and \texttt{docker compose ps} lists container ports only
|
|
(Section~\ref{sec:sre-deploy}). Prometheus (9090), Node Exporter (9100), and
|
|
Blackbox Exporter (9115) are reachable only from other containers on the
|
|
\texttt{monitoring} network.
|
|
|
|
The first external test (below) showed that Grafana's \texttt{/metrics}
|
|
endpoint was readable without a login, because the original Grafana site block
|
|
in the Caddyfile (\texttt{/root/gitea/Caddyfile}) forwarded every path:
|
|
\begin{minted}[fontsize=\footnotesize]{text}
|
|
metrics.ssw590-08.me {
|
|
encode gzip
|
|
reverse_proxy grafana:3000
|
|
}
|
|
\end{minted}
|
|
The block was then changed to answer \texttt{/metrics} with 404 and forward
|
|
everything else, and Caddy's configuration was validated and reloaded:
|
|
\begin{minted}[fontsize=\footnotesize]{text}
|
|
metrics.ssw590-08.me {
|
|
encode gzip
|
|
handle /metrics* {
|
|
respond "Not found" 404
|
|
}
|
|
handle {
|
|
reverse_proxy grafana:3000
|
|
}
|
|
}
|
|
\end{minted}
|
|
Prometheus scrapes Grafana's own metrics, if at all, over the internal network and
|
|
not through Caddy, so the block does not affect the monitoring configuration.
|
|
|
|
\subsection{External Exposure Tests}
|
|
\label{sec:sre-exposure-tests}
|
|
The tests below must be run from a machine outside the Droplet. A test run on
|
|
the Droplet itself shows only what is listening, not what the network allows.
|
|
\begin{minted}[breaklines,breakanywhere]{bash}
|
|
date -u +%Y-%m-%dT%H:%M:%SZ
|
|
for p in 3000 3001 9090 9100 9115; do nc -vz -w 3 147.182.179.191 $p; done
|
|
for u in https://git.ssw590-08.me/user/login https://ci.ssw590-08.me/login \
|
|
https://metrics.ssw590-08.me/login https://metrics.ssw590-08.me/d/ssw590-sre \
|
|
https://metrics.ssw590-08.me/metrics; do
|
|
printf '%s ' "$u"; curl -sS -o /dev/null -w '%{http_code}\n' "$u"
|
|
done
|
|
\end{minted}
|
|
|
|
\textbf{Machine and network.} The tests were run from a team member's MacBook
|
|
(macOS) that is not on the Droplet, on October 30, 2026. The first run was at
|
|
about 9:20--9:25~PM EDT; its own \texttt{date -Is} timestamp failed because macOS
|
|
\texttt{date} does not support that option, so the command above uses a portable
|
|
format. After the Caddy change, the full block was repeated and then the two
|
|
Grafana URLs were re-checked with a timestamp of
|
|
2026-10-31T01:44:20Z (9:44~PM EDT).
|
|
|
|
\begin{tabularx}{\linewidth}{L{4.2cm}YL{4.2cm}}
|
|
\toprule
|
|
\textbf{Test} & \textbf{Expected} & \textbf{Actual}\\ \midrule
|
|
TCP 3000, 3001, 9090, 9100, 9115 on the public IPv4 address & Refused or timed
|
|
out: nothing is published on the host & All five timed out, before and after
|
|
the change\\
|
|
Gitea, Jenkins, and Grafana login pages & HTTP 200 over HTTPS & 200, 200, 200\\
|
|
Grafana dashboard URL without a session & Redirect (302) to the login page &
|
|
302\\
|
|
\nolinkurl{https://metrics.ssw590-08.me/metrics} & Not served publicly. A 200
|
|
response would mean Grafana's own metrics are readable from the Internet and
|
|
should be blocked at Caddy & \textbf{Before the Caddy change: 200 (exposed).
|
|
After: 404}\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
\begin{itemize}
|
|
\item \textbf{Finding.} Before the change, \texttt{/metrics} on the Grafana
|
|
hostname returned 200 to an unauthenticated client
|
|
(Figure~\ref{fig:sre-expose-before}). The page describes Grafana's own
|
|
internals; the host and probe metrics come from separate, unpublished
|
|
services. The path was nevertheless not meant to be public, so it was
|
|
blocked in Caddy.
|
|
\item \textbf{After the change,} the repeat shows 404 for \texttt{/metrics}
|
|
while the login page still returns 200
|
|
(Figures~\ref{fig:sre-expose-after} and~\ref{fig:sre-expose-recheck}).
|
|
\item \textbf{IPv6.} \texttt{dig AAAA metrics.ssw590-08.me +short} printed
|
|
nothing, so the hostname has no IPv6 record and no IPv6 path was tested.
|
|
\item \textbf{Scope.} The five ports were tested from this one outside
|
|
network only. The result shows what was reachable, not why: the Cloud Firewall
|
|
rules (Section~\ref{sec:ci-https}) were not examined as part of this test.
|
|
\end{itemize}
|
|
|
|
\srefig{exposure-before.png}{0.9}{October 30, 2026, about 9:20--9:25~PM EDT, from
|
|
an outside machine --- all five ports time out, but \texttt{/metrics} returns
|
|
200.}{fig:sre-expose-before}
|
|
|
|
\srefig{exposure-after.png}{0.9}{October 30, 2026, after the Caddy change --- the
|
|
same test; \texttt{/metrics} now returns 404 (no timestamp, because the macOS
|
|
\texttt{date} option failed).}{fig:sre-expose-after}
|
|
|
|
\srefig{exposure-recheck.png}{0.9}{October 30, 2026, 2026-10-31T01:44:20Z --- a
|
|
timestamped re-check: Grafana login 200, \texttt{/metrics} 404.}{fig:sre-expose-recheck}
|
|
\section{Dashboard and CI Correlation}
|
|
\label{sec:sre-dashboard}
|
|
|
|
\subsection{Team Dashboard}
|
|
The dashboard \textbf{``SSW 590 -- Gitea \& Jenkins Reliability''} (uid
|
|
\texttt{ssw590-sre}, folder ``SSW 590'') was written for this deployment; it is
|
|
not an imported community dashboard. It is opened at
|
|
\url{https://metrics.ssw590-08.me/d/ssw590-sre} after login. Its definition is
|
|
versioned in Gitea as
|
|
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/monitoring/grafana/dashboards/ssw590-sre.json}{\texttt{monitoring/grafana/dashboards/ssw590-sre.json}}.
|
|
Grafana loads it at startup through the file provider in
|
|
\texttt{grafana/provisioning/dashboards/dashboards.yml}, so a rebuilt Grafana
|
|
container gets the same dashboard without manual steps.
|
|
|
|
\begin{itemize}
|
|
\item \textbf{Time zone:} America/New\_York (EDT/EST), shown in the time
|
|
picker.
|
|
\item \textbf{Default range and refresh:} last 6 hours, refreshing every
|
|
30 seconds to match the scrape interval.
|
|
\item \textbf{Data source:} the provisioned Prometheus data source
|
|
(\texttt{http://prometheus:9090}).
|
|
\item Every panel has a legend, a unit, and a description (the \emph{i} icon)
|
|
explaining its query.
|
|
\end{itemize}
|
|
|
|
\begin{tabularx}{\linewidth}{L{4.4cm}Y}
|
|
\toprule
|
|
\textbf{Panel (unit)} & \textbf{Meaning and thresholds}\\ \midrule
|
|
1. Droplet CPU utilization (\%) & Share of CPU time not idle, averaged across
|
|
CPUs. CPU time is a counter, so the panel uses its 2-minute \texttt{rate}
|
|
rather than the raw total. Orange at 70\%, red at 90\%.\\
|
|
2. Available host memory (bytes, IEC) & The kernel's estimate of memory
|
|
available to new programs without swapping; not the same as unused RAM.
|
|
Orange below 400~MiB, red below 200~MiB.\\
|
|
3. Root filesystem available (\%) & Available bytes divided by size bytes for
|
|
the host root filesystem \texttt{/dev/vda1} only. The selector excludes
|
|
overlay and pseudo filesystems. Orange below 25\%, red below 15\% (the alert
|
|
threshold).\\
|
|
4. Gitea HTTPS availability (0/1) & 1 = probe succeeded, 0 = failed, shown as
|
|
UP/DOWN.\\
|
|
5. Jenkins HTTPS availability (0/1) & Same as panel 4, for Jenkins.\\
|
|
6. HTTPS probe duration (s) & Total probe time, including DNS, connection, TLS,
|
|
and request; one labeled line per service.\\
|
|
Scrape health (0/1) & Collection health for every target. It is separate from
|
|
\texttt{probe\_success}: \texttt{up} can be 1 while a probe fails.\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
The panel queries, in the same order:
|
|
\begin{minted}[fontsize=\footnotesize,breaklines,breakanywhere]{text}
|
|
1 100 * (1 - avg(rate(node_cpu_seconds_total{job="node",mode="idle"}[2m])))
|
|
2 node_memory_MemAvailable_bytes{job="node"}
|
|
3 100 * node_filesystem_avail_bytes{job="node",mountpoint="/",device="/dev/vda1"}
|
|
/ node_filesystem_size_bytes{job="node",mountpoint="/",device="/dev/vda1"}
|
|
4 probe_success{job="https",instance="https://git.ssw590-08.me/user/login"}
|
|
5 probe_success{job="https",instance="https://ci.ssw590-08.me/login"}
|
|
6 probe_duration_seconds{job="https"} (legend: {{instance}})
|
|
+ up (legend: {{job}} {{instance}})
|
|
\end{minted}
|
|
|
|
\medskip
|
|
All host panels describe the whole Droplet: Gitea, Jenkins, Caddy, and the
|
|
monitoring stack together. They cannot attribute CPU or memory to an
|
|
individual container.
|
|
|
|
\srefig{dashboard-full.png}{1.0}{October 29, 2026, about 6:35 PM EDT --- the team
|
|
dashboard over the last 2 days, with all six required panels. Panel 5 shows the
|
|
controlled Jenkins outage at 4:09--4:13 PM on October 29; Gitea (panel 4) stays
|
|
UP.}{fig:sre-dashboard-full}
|
|
|
|
\subsection{Normal Build Comparison}
|
|
Two normal runs of the existing pipeline on \texttt{main} were observed. Both
|
|
ran commit \texttt{3301e24} on the Jenkins controller's built-in node, inside
|
|
the \texttt{jenkins} container, as shown by ``Running on Jenkins'' in the
|
|
console log.
|
|
|
|
\textbf{Run \#6, measured with \texttt{docker stats} before the dashboard
|
|
existed.} Run \#6 lasted 6.8 seconds, from 3:44:57 to 3:45:04 PM EDT on
|
|
October 28, 2026. \texttt{docker stats} and \texttt{free -b} were sampled every
|
|
4 seconds from 3:44:23 to 3:47:06 PM:
|
|
|
|
\begin{tabularx}{\linewidth}{L{3.6cm}Y}
|
|
\toprule
|
|
\textbf{Window (EDT)} & \textbf{Observation}\\ \midrule
|
|
Before (3:44:23--3:44:28) & \texttt{jenkins} about 0.3\% CPU, 695.5~MiB;
|
|
host MemAvailable about 774~MB\\
|
|
During (3:45:01--3:45:06) & \texttt{jenkins} 41.7\% then 12.1\% CPU;
|
|
\texttt{gitea} 49.7\% (checkout fetch and status update);
|
|
\texttt{jenkins} 699--700~MiB\\
|
|
After (3:45:10 onward) & All containers below 1\% CPU; host MemAvailable
|
|
about 765~MB\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
Two other short spikes, at 3:44:32 (\texttt{jenkins} 59\%) and 3:46:08 PM
|
|
(\texttt{gitea} 48\%), fall outside the build window. They are probably the
|
|
Multibranch job's periodic repository scan, but the data cannot attribute them.
|
|
|
|
\textbf{Run \#7, on the dashboard.} Run \#7 started at 5:46:58 PM EDT on
|
|
October 28, 2026 and took 5.1 seconds. Jenkins displays this time as 9:46:58
|
|
PM UTC. Figure~\ref{fig:sre-dashboard-build} shows the 15 minutes around it.
|
|
|
|
\srefig{dashboard-build7.png}{1.0}{October 28, 2026, about 5:34--5:49 PM EDT
|
|
--- dashboard panels 1--3 and 6 around Jenkins \texttt{main} run \#7
|
|
(5:46:58 PM, 5.1 s).}{fig:sre-dashboard-build}
|
|
|
|
\textbf{Interpretation.}
|
|
\begin{itemize}
|
|
\item No distinct spike is visible at 5:47 PM. The build lasted 5.1 seconds,
|
|
shorter than the 30-second scrape interval, and panel 1 shows a 2-minute
|
|
rate. A 5-second burst of about 40\% on one container therefore adds only a
|
|
few percent to the 2-minute average, which falls within the normal
|
|
variation of 10--20\%.
|
|
\item The larger CPU rise to about 37\% between 5:42 and 5:45 PM, and the
|
|
drop in available memory at the same time, \emph{precede} the build. They may come
|
|
from Grafana restarting shortly before to load the new dashboard, but that
|
|
restart time was not recorded. The whole-host metrics cannot show which
|
|
process was responsible, so these changes are not attributed to Jenkins.
|
|
\item The \texttt{docker stats} sampling of run \#6 is the clearer evidence:
|
|
a normal build is a CPU burst of under 10 seconds with a negligible memory
|
|
effect (about 10~MB). The host has CPU and memory headroom for builds while
|
|
monitoring runs.
|
|
\item Root-filesystem space stayed flat at about 82\% available. Builds do
|
|
not consume measurable disk space.
|
|
\end{itemize}
|
|
\section{SLI, SLO, and Error Budget}
|
|
\label{sec:sre-slo}
|
|
|
|
\subsection{Definitions and Worked Example}
|
|
Three terms are used in this chapter, following the Google SRE
|
|
Workbook~\cite{SREWorkbook}:
|
|
\begin{tabularx}{\linewidth}{L{2.2cm}Y}
|
|
\toprule
|
|
\textbf{Term} & \textbf{Meaning in this report}\\ \midrule
|
|
\gls{sli} & A measured indicator. Here: the share of scheduled HTTPS probes that
|
|
succeed for one service over a stated window, computed as
|
|
\texttt{100 * avg\_over\_time(probe\_success\{\ldots\}[window])}.\\
|
|
\gls{slo} & An internal target for the \gls{sli}: at least 99\% of probes
|
|
succeed over a 24-hour lab window, evaluated separately for Gitea and
|
|
Jenkins. The 99\% figure is an instructional choice, not a production
|
|
promise.\\
|
|
\gls{sla} & An agreement with a customer that may carry consequences if it is
|
|
missed. None exists for this lab, so no \gls{sla} applies.\\
|
|
\gls{errorbudget} & The failure the \gls{slo} allows: 1\% of the scheduled probes
|
|
in the window.\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
The difference in one line: the \gls{sli} is what was measured, the \gls{slo}
|
|
is what the team wants it to be, and an \gls{sla} would be a promise to someone
|
|
else with a penalty attached.
|
|
|
|
\textbf{Worked example (hypothetical figures, not lab results).} These numbers
|
|
come from the assignment's illustration. At a 30-second probe interval, one
|
|
service is probed $24 \times 60 \times 2 = 2{,}880$ times a day. Suppose there
|
|
are no missing observations, Gitea succeeds 2,880 times with no failures, and
|
|
Jenkins succeeds 2,850 times and fails 30 times.
|
|
|
|
\begin{tabularx}{\linewidth}{L{2.4cm}L{2.4cm}L{2.4cm}L{2.2cm}Y}
|
|
\toprule
|
|
\textbf{Service} & \textbf{Successes} & \textbf{Failures} & \textbf{SLI} &
|
|
\textbf{Meets 99\%?}\\ \midrule
|
|
Gitea & 2,880 & 0 & 100\% & Yes\\
|
|
Jenkins & 2,850 & 30 & $100 \times 2850/2880 \approx 98.96\%$ & No\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
\begin{itemize}
|
|
\item \textbf{Budget.} 1\% of 2,880 probes is $0.01 \times 2880 = 28.8$
|
|
failed samples. With samples spread evenly, each stands for 30 seconds, so
|
|
the budget is $28.8 \times 30\,\text{s} = 864\,\text{s} = 14.4$ minutes of
|
|
failure a day.
|
|
\item \textbf{Jenkins overspends it.} 30 failures exceed the budget by
|
|
$30 - 28.8 = 1.2$ samples, about 0.6 minutes, so Jenkins has used about
|
|
104\% of its budget and misses the target.
|
|
\item \textbf{Whole samples.} Failures are counted in whole samples, so at most
|
|
28 failures meet the target: 28 failures give
|
|
$2852/2880 \approx 99.03\%$, while 29 give $2851/2880 \approx 98.99\%$.
|
|
\item \textbf{Gitea} has used none of its budget.
|
|
\end{itemize}
|
|
The measured exercise in Section~\ref{sec:sre-short-window} uses the same
|
|
method, but its 10-minute window cannot establish a 24-hour result.
|
|
|
|
\subsection{Measured Short Window: Controlled Jenkins Outage}
|
|
\label{sec:sre-short-window}
|
|
|
|
The following \gls{sli} figures are \textbf{measured results} from this deployment, not the
|
|
hypothetical figures above. Following the SLO approach of the Google SRE Workbook~\cite{SREWorkbook}, the window spans the controlled Jenkins outage in
|
|
Section~\ref{sec:sre-incident}:
|
|
|
|
\begin{tabularx}{\linewidth}{L{4.4cm}Y}
|
|
\toprule
|
|
\textbf{Parameter} & \textbf{Value}\\ \midrule
|
|
Window & October 29, 2026, 4:06:00--4:16:00 PM EDT (20:06:00--20:16:00 UTC), 10 minutes\\
|
|
Query evaluation time & 4:16:00 PM EDT (Unix time 1793304960)\\
|
|
Scrape interval & 30 seconds, so about 20 samples are expected per service\\
|
|
Series & \texttt{probe\_success\{job="https"\}}, one per \texttt{instance}\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
The queries were sent to the Prometheus HTTP API from inside the Prometheus
|
|
container, with \texttt{time=2026-10-29T20:16:00Z}:
|
|
\begin{minted}[breaklines,breakanywhere]{text}
|
|
100 * avg_over_time(probe_success{job="https",instance="https://ci.ssw590-08.me/login"}[10m])
|
|
count_over_time(probe_success{job="https",instance="https://ci.ssw590-08.me/login"}[10m])
|
|
\end{minted}
|
|
The same two queries were repeated for
|
|
\nolinkurl{https://git.ssw590-08.me/user/login}.
|
|
|
|
\begin{tabularx}{\linewidth}{L{2.4cm}L{2.2cm}L{2.2cm}L{2.4cm}Y}
|
|
\toprule
|
|
\textbf{Service} & \textbf{Received} & \textbf{Expected} & \textbf{Successful} & \textbf{Success (received samples)}\\ \midrule
|
|
Jenkins & 20 & $\approx$20 & 11 & 55.0\%\\
|
|
Gitea & 20 & $\approx$20 & 20 & 100.0\%\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
\textbf{Interpretation.}
|
|
\begin{itemize}
|
|
\item The Jenkins series contains nine consecutive failed samples, from
|
|
4:09:12 to 4:13:12 PM, between successful samples at 4:08:42 and
|
|
4:13:42 PM. This matches the deliberate stop at 4:08:54 PM and the restart at
|
|
4:12:29 PM (Section~\ref{sec:sre-incident}).
|
|
\item Gitea stayed at 100\%. The outage was limited to Jenkins, and the probe
|
|
distinguishes the two services.
|
|
\item All 20 expected samples were received for each service, so coverage is
|
|
complete and no observation is missing. Had samples been missing, they would
|
|
be treated as unknown and excluded, never counted as successes. The samples
|
|
fall at 12 and 42 seconds past each minute. A window boundary placed
|
|
differently could therefore contain 19 or 21 samples.
|
|
\item This 10-minute percentage describes only the exercise window. It cannot
|
|
establish the 24-hour \gls{slo}. For illustration only: if these nine failures were
|
|
the only failures in a full day of 2,880 scheduled probes, Jenkins would
|
|
measure $2871/2880 \approx 99.69\%$. That would meet the 99\% target and use
|
|
$9/28.8 \approx 31\%$ of the daily \gls{errorbudget}. No full-day result is
|
|
claimed here.
|
|
\end{itemize}
|
|
|
|
\srefig{sli-short-window.png}{0.9}{October 29, 2026 --- Grafana Explore instant
|
|
queries at 4:16:00 PM EDT: Jenkins 55\% over 20 samples, Gitea 100\% over 20
|
|
samples.}{fig:sre-sli-window}
|
|
\section{Alerts and Runbooks}
|
|
\label{sec:sre-alerts}
|
|
|
|
\subsection{Notification Destination}
|
|
\textbf{First attempt: email (failed).} An Email contact point was configured
|
|
with Gmail SMTP (\texttt{smtp.gmail.com:587}, STARTTLS, app password in
|
|
\texttt{grafana.secrets.env}). The contact-point test failed with:
|
|
\begin{minted}[breaklines,breakanywhere]{text}
|
|
failed to send email: dial tcp 172.253.122.109:587: i/o timeout
|
|
\end{minted}
|
|
The connection never reached Gmail. DigitalOcean blocks outbound SMTP ports
|
|
25, 465, and 587 on Droplets by default~\cite{DOSMTP}, so the problem was the
|
|
network path, not the credentials. Because email cannot leave this Droplet on
|
|
those ports, the \texttt{GF\_SMTP\_*} settings were removed from
|
|
\texttt{grafana.secrets.env} and the Gmail app password was revoked.
|
|
|
|
\textbf{Final destination: Discord webhook.} The contact point
|
|
\texttt{team-alerts} uses Grafana's dedicated \emph{Discord} integration,
|
|
posting to the \texttt{\#general} channel of the team's private Discord server.
|
|
It sends over HTTPS (port 443), which the Droplet may use. Resolved messages
|
|
are enabled. The webhook URL is a secret: it is stored only in Grafana's
|
|
database, in the \texttt{monitoring\_\allowbreak grafana\_\allowbreak data} volume, and never in Git or
|
|
in screenshots. When rebuilding, a team member re-creates the contact point and
|
|
pastes the URL from Discord (\emph{Channel settings $\rightarrow$ Integrations
|
|
$\rightarrow$ Webhooks}).
|
|
|
|
\srefig{contact-point-test.png}{0.85}{October 28, 2026, 8:19 PM EDT --- test
|
|
notification from contact point \texttt{team-alerts} received in Discord. This
|
|
verifies delivery only, not the rule queries or routing.}{fig:sre-cp-test}
|
|
|
|
\srefig{contact-points.png}{0.75}{Grafana contact points: \texttt{team-alerts}
|
|
(Discord) is used by the alert rule. The built-in \texttt{empty} contact point is
|
|
attached only to the default notification policy and receives no team
|
|
alerts.}{fig:sre-contact-points}
|
|
|
|
\subsection{Rule 1: \texttt{ServiceUnavailable}}
|
|
Both rules are Grafana-managed alerts evaluated by Grafana's built-in Alertmanager~\cite{GrafanaAlerting}; no separate Alertmanager is deployed.
|
|
|
|
\begin{tabularx}{\linewidth}{L{3.6cm}Y}
|
|
\toprule
|
|
\textbf{Setting} & \textbf{Value}\\ \midrule
|
|
Type & Grafana-managed alert rule, uid \texttt{fg2n29o6c9a80d}, folder ``SSW 590''\\
|
|
Owner & \texttt{samahk13} (label \texttt{owner}); backup \texttt{kholmes}\\
|
|
Severity & \texttt{critical} (label \texttt{severity}); label \texttt{team=ssw590}\\
|
|
Query (A) & \texttt{probe\_success\{job="https"\}}, instant, Prometheus data source\\
|
|
Condition & Fires when the query \textbf{is below 1}, evaluated separately for
|
|
each \texttt{instance}, so Gitea and Jenkins alert independently\\
|
|
Evaluation & Group \texttt{availability}, every 30 seconds\\
|
|
Pending period & 1 minute: a probe must fail for at least 1 minute before the
|
|
rule fires\\
|
|
No data & \textbf{Alerting}. A missing \texttt{probe\_success} series, for
|
|
example because Blackbox Exporter or Prometheus is down, raises the alert
|
|
instead of looking healthy\\
|
|
Error or timeout & \textbf{Alerting}. A failed query is treated as a monitoring
|
|
failure that needs attention\\
|
|
Routing & Simplified routing directly to contact point \texttt{team-alerts}\\
|
|
Notification timing & Group wait 30 s, group interval 5 min, repeat interval 4 h\\
|
|
Summary & \texttt{\{\{ \$labels.instance \}\} HTTPS probe failing for 1m}\\
|
|
Runbook & \href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/monitoring/RUNBOOK.md}{\texttt{monitoring/RUNBOOK.md}}, section ServiceUnavailable\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
\textbf{Expected delay to notification.} After a service goes down, the next
|
|
probe fails within 30 seconds, and the next 30-second evaluation moves the rule
|
|
to Pending. It fires once the 1-minute pending period has passed. The group
|
|
wait adds 30 seconds before the message is sent. The worst case is therefore
|
|
about 2.5 minutes. The controlled outage measured 1 minute 46 seconds to Firing
|
|
and about 2--2.5 minutes to the Discord message
|
|
(Section~\ref{sec:sre-incident}).
|
|
|
|
\textbf{Response.} The on-call owner follows \texttt{RUNBOOK.md}:
|
|
\begin{enumerate}
|
|
\item Acknowledge in Discord.
|
|
\item Check the scrape-health row to tell a monitoring failure from a service
|
|
failure.
|
|
\item Check the URL in a browser.
|
|
\item Inspect \texttt{docker ps -a} and the container logs.
|
|
\item Restore with \texttt{docker start} or \texttt{docker restart} on the
|
|
affected container. Never use \texttt{down -v}.
|
|
\item Confirm the Resolved message.
|
|
\item Run a Jenkins build, and check the Gitea login and webhook.
|
|
\end{enumerate}
|
|
|
|
\srefig{rule-query.png}{0.8}{\texttt{ServiceUnavailable} rule: query
|
|
\texttt{probe\_success\{job="https"\}}, evaluation every 30 s, notifications to
|
|
\texttt{team-alerts}, runbook URL, and owner, severity, and team
|
|
labels.}{fig:sre-rule}
|
|
|
|
\srefig{rule-instances.png}{0.75}{The rule's two alert instances, one per
|
|
probed URL. Both are Normal and both route to \texttt{team-alerts}.}{fig:sre-rule-instances}
|
|
|
|
\textbf{Configuration error found during setup.} When the rule was first
|
|
created, its condition was \emph{``is above 0''}
|
|
(Figure~\ref{fig:sre-rule-misconfigured}). A healthy probe returns 1, so the
|
|
condition was true whenever the services were \emph{up}. The rule went to
|
|
Pending at 8:29:40 PM and to Firing at 8:30:40 PM on October 28 while both
|
|
services were healthy (\texttt{A=1}). The condition was corrected to
|
|
\emph{``is below 1''} at 8:37:10 PM, and both instances returned to Normal
|
|
(Figure~\ref{fig:sre-incident-history}). The rule's summary annotation had also
|
|
been set to the runbook URL; it was corrected after the incident exercise.
|
|
|
|
\srefig{rule-misconfigured.png}{0.8}{The original, incorrect alert condition
|
|
(\emph{is above 0}), which fired while both services were healthy. It was
|
|
replaced by \emph{is below 1}.}{fig:sre-rule-misconfigured}
|
|
|
|
\textbf{Firing, delivery, and resolution.} The controlled Jenkins outage on
|
|
October 29 drove this rule through a real cycle:
|
|
\begin{itemize}
|
|
\item Pending at 4:09:40 PM and Firing at 4:10:40 PM;
|
|
\item Discord Firing message at 4:11 PM;
|
|
\item Normal at 4:14:10 PM;
|
|
\item Discord Resolved message at 4:16 PM.
|
|
\end{itemize}
|
|
The full timeline is in Section~\ref{sec:sre-incident} and
|
|
Figures~\ref{fig:sre-incident-discord} and~\ref{fig:sre-incident-history}.
|
|
|
|
\textbf{Versioned definition.} The final rules, including \texttt{HostDiskLow}
|
|
(Section~\ref{sec:sre-hostdisk}), are exported (\emph{Alert rule
|
|
$\rightarrow$ More $\rightarrow$ Export}, YAML) to
|
|
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/monitoring/grafana/alerting/alert-rules.yaml}{\texttt{monitoring/grafana/alerting/alert-rules.yaml}}.
|
|
The export contains the contact-point name only, not the webhook URL.
|
|
|
|
\subsection{Rule 2: \texttt{HostDiskLow}}
|
|
\label{sec:sre-hostdisk}
|
|
The second Grafana-managed rule watches free space on the Droplet's root
|
|
filesystem. It uses the same \texttt{/dev/vda1} device that the dashboard's Disk
|
|
Usage panel reports, so the alert and the dashboard describe one filesystem and
|
|
are not mixed with container or pseudo filesystems.
|
|
|
|
\begin{tabularx}{\linewidth}{L{3.6cm}Y}
|
|
\toprule
|
|
\textbf{Setting} & \textbf{Value}\\ \midrule
|
|
Type & Grafana-managed alert rule, uid \texttt{bg2tu8l6pb20wc}, folder
|
|
``SSW 590'', rule group \texttt{infrastructure-alerts}\\
|
|
Owner & \texttt{kholmes7} (label \texttt{owner})\\
|
|
Severity & \texttt{warning} (label \texttt{severity}); label
|
|
\texttt{team=ssw590}\\
|
|
Query (A) & Prometheus data source, relative range 10 minutes to now, instant:
|
|
\texttt{100 * node\_filesystem\_avail\_bytes\{mountpoint="/", fstype!="rootfs", device="/dev/vda1"\}
|
|
/ node\_filesystem\_size\_bytes\{\ldots same selector\ldots\}}. The result is
|
|
the \emph{percentage of the filesystem that is free}.\\
|
|
Condition (C) & Threshold on A: \textbf{is below 15}. The series returned has
|
|
\texttt{device="/dev/vda1"}, \texttt{fstype="ext4"},
|
|
\texttt{instance="node-exporter:9100"}, \texttt{job="node"},
|
|
\texttt{mountpoint="/"}\\
|
|
Evaluation & Group \texttt{infrastructure-alerts}, every \textbf{30 seconds}
|
|
(Figure~\ref{fig:sre-disk-eval})\\
|
|
Pending period & \textbf{5 minutes}: free space must stay below the threshold
|
|
for five minutes before the rule fires. Keep firing for 0 s
|
|
(Figure~\ref{fig:sre-disk-eval})\\
|
|
No data and error & \textbf{Alerting} for both \emph{no data or all values
|
|
null} and \emph{execution error or timeout}
|
|
(Figure~\ref{fig:sre-disk-settings}). If \texttt{node-exporter} stops
|
|
reporting the root-filesystem series, or the query fails, the rule alerts
|
|
instead of looking healthy\\
|
|
Notification & Contact point \texttt{team-alerts} (Discord;
|
|
Figure~\ref{fig:sre-disk-settings})\\
|
|
Summary & \texttt{Root filesystem free space below 15\% on node-exporter:9100}\\
|
|
Description & Investigate root filesystem capacity on the monitored Droplet.
|
|
Check disk usage and Docker logs before taking action. Do not delete Docker
|
|
volumes or container data as an emergency response.\\
|
|
Runbook & \href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/monitoring/RUNBOOK.md}{\texttt{monitoring/RUNBOOK.md}}\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\srefig{hostdisklow-rule.png}{0.8}{October 30, 2026, 6:06 PM EDT ---
|
|
\texttt{HostDiskLow} rule in folder \emph{SSW 590}, group
|
|
\texttt{infrastructure-alerts}. Query A computes the free-space percentage of
|
|
\texttt{/dev/vda1} mounted at \texttt{/} (about 81.72\% free), and threshold C
|
|
(\emph{alert condition}) is \emph{is below 15}. The instance is Normal.}{fig:sre-disk-rule}
|
|
|
|
\srefig{hostdisklow-eval.png}{0.6}{October 30, 2026, 6:54 PM EDT --- evaluation
|
|
behavior of \texttt{HostDiskLow}: group \texttt{infrastructure-alerts} is
|
|
evaluated every 30 s, the pending period is 5 minutes, and keep firing for is
|
|
0 s.}{fig:sre-disk-eval}
|
|
|
|
\srefig{hostdisklow-settings.png}{0.5}{October 30, 2026, 6:37 PM EDT ---
|
|
\texttt{HostDiskLow} saved settings: pending period 5 minutes, contact point
|
|
\texttt{team-alerts}, and \emph{Alerting} as the state for both no data and
|
|
execution error or timeout.}{fig:sre-disk-settings}
|
|
|
|
\textbf{Why 15\%, and what the operator does.} At the time of the test, about
|
|
82\% of the root filesystem was free, so the rule was far from firing. The 15\%
|
|
threshold is the assignment's capacity limit: it warns while there is still room
|
|
to investigate before builds, image pulls, or monitoring data run out of space.
|
|
The on-call owner follows the rule's description and \texttt{RUNBOOK.md}:
|
|
\begin{enumerate}
|
|
\item Acknowledge the message in Discord.
|
|
\item Check disk usage on the Droplet and the Docker container logs
|
|
\emph{before} taking any action, to find what is consuming space.
|
|
\item Free space only from data that is known to be disposable. Do not delete
|
|
Docker volumes or container data as an emergency response, and never run
|
|
\texttt{docker compose down -v}.
|
|
\item Confirm that the Resolved message arrives and that free space is back
|
|
above 15\%.
|
|
\end{enumerate}
|
|
|
|
\textbf{Safe test.} The disk was not filled. Instead, the rule's threshold was
|
|
temporarily raised from 15 to \textbf{85} (Figure~\ref{fig:sre-disk-85}). The
|
|
real free space was about 81.7\%, which is below 85, so the real query result
|
|
counted as ``low'' and the condition evaluated to true. After the 5-minute
|
|
pending period the rule fired and Discord delivered the message. The threshold
|
|
was then restored to 15, and the rule resolved.
|
|
|
|
\textbf{First run and repeat.} An earlier run of this test went from Pending
|
|
(6:13:30 PM) to Alerting (6:16:00 PM) in only 2 minutes 30 seconds, shorter than
|
|
the required five minutes (Figure~\ref{fig:sre-disk-history}). The test was
|
|
therefore repeated with the 5-minute pending period confirmed in
|
|
Figure~\ref{fig:sre-disk-eval}. The repeat is the evidence below.
|
|
|
|
\begin{tabularx}{\linewidth}{L{2.5cm}YL{3.3cm}}
|
|
\toprule
|
|
\textbf{Time (EDT)} & \textbf{Event} & \textbf{Evidence}\\ \midrule
|
|
6:06 PM & Threshold is \emph{below 15}; query returns about 81.72; rule Normal
|
|
& Figure~\ref{fig:sre-disk-rule}\\
|
|
6:53:20 PM & Rule updated: threshold raised to 85 (\emph{Normal (Updated)})
|
|
& Figure~\ref{fig:sre-disk-history-repeat}\\
|
|
6:53:30 PM & \textbf{Pending}, \texttt{A=81.718367}, \texttt{C=1}
|
|
& Figure~\ref{fig:sre-disk-history-repeat}\\
|
|
6:54 PM & Pending period confirmed as 5 minutes; evaluation every 30 s
|
|
& Figure~\ref{fig:sre-disk-eval}\\
|
|
6:58:30 PM & \textbf{Alerting} after exactly 5 minutes pending,
|
|
\texttt{A=81.713006}, \texttt{C=1}
|
|
& Figure~\ref{fig:sre-disk-history-repeat}\\
|
|
6:59 PM & \textbf{Firing} message in Discord, \texttt{A=81.71300563363819},
|
|
\texttt{C=1} & Figure~\ref{fig:sre-disk-firing}\\
|
|
6:59:30 PM & Rule updated: threshold restored to 15 (\emph{Normal (Updated)})
|
|
& Figure~\ref{fig:sre-disk-history-repeat}\\
|
|
7:04 PM & \textbf{Resolved} message in Discord & Figure~\ref{fig:sre-disk-resolved}\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
\textbf{Result.} Pending to Alerting took exactly 5 minutes (6:53:30 PM to
|
|
6:58:30 PM), matching the configured pending period. The Firing message arrived
|
|
within the same minute as the Alerting state. The Resolved message arrived at
|
|
7:04 PM, about 4.5 minutes after the rule was restored at 6:59:30 PM. This is
|
|
consistent with Grafana sending the resolved update at the next notification
|
|
group interval (5 minutes for the other rule,
|
|
Section~\ref{sec:sre-alerts}), not with a delivery fault. The restoration was
|
|
therefore seen in Discord later than it happened in Grafana.
|
|
|
|
\srefig{hostdisklow-history-repeat.png}{0.85}{October 30, 2026 --- state history
|
|
of \texttt{HostDiskLow} for the repeat run: Normal (Updated) at 6:53:20 PM,
|
|
Pending at 6:53:30 PM, Alerting at 6:58:30 PM, and Normal (Updated) at
|
|
6:59:30 PM.}{fig:sre-disk-history-repeat}
|
|
|
|
\srefig{hostdisklow-threshold-85.png}{1.0}{October 30, 2026, 6:39 PM EDT ---
|
|
the alert condition editor showing the temporary threshold, \emph{when query is
|
|
below 85}. The saved rule was restored to 15
|
|
(Figure~\ref{fig:sre-disk-normal}).}{fig:sre-disk-85}
|
|
|
|
\srefig{hostdisklow-firing.png}{0.85}{October 30, 2026, 6:59 PM EDT --- Grafana
|
|
\emph{Firing} message for \texttt{HostDiskLow} in Discord. \texttt{A} is the
|
|
measured free-space percentage (81.71) and \texttt{C=1} means the temporary
|
|
threshold condition was true. The labels identify the device, filesystem,
|
|
owner, severity, and team, and the runbook link is included.}{fig:sre-disk-firing}
|
|
|
|
\srefig{hostdisklow-resolved.png}{0.85}{October 30, 2026, 7:04 PM EDT ---
|
|
Grafana \emph{Resolved} message for \texttt{HostDiskLow}, received after the
|
|
threshold was restored. The value is \texttt{[no value]} and
|
|
\texttt{grafana\_state\_reason} is \texttt{Updated}, which Grafana reports when
|
|
a rule is edited: the instance was resolved because the rule changed, not
|
|
because the free-space value moved.}{fig:sre-disk-resolved}
|
|
|
|
\srefig{disk-usage-panel.png}{0.85}{October 30, 2026, 6:20:15 PM EDT --- the
|
|
dashboard's Disk Usage panel reports 18.2\% used on \texttt{/dev/vda1} at
|
|
\texttt{/}. This agrees with the alert query's 81.72\% free (18.28\% used) to
|
|
within 0.1 percentage point, so the alert and the dashboard describe the same
|
|
filesystem.}{fig:sre-disk-usage}
|
|
|
|
\srefig{hostdisklow-normal.png}{1.0}{October 30, 2026, 6:22 PM EDT --- restored
|
|
settings. The query returns 81.72035 for the \texttt{/dev/vda1} series, and the
|
|
alert condition is \emph{when query is below 15}, which evaluates to 0
|
|
(\textbf{Normal}).}{fig:sre-disk-normal}
|
|
|
|
\srefig{hostdisklow-history.png}{0.85}{October 30, 2026 --- state history of
|
|
\texttt{HostDiskLow} for the first run: Normal (Updated) at 6:13:20 PM, Pending
|
|
at 6:13:30 PM, Alerting at 6:16:00 PM, and Normal (Updated) at 6:17:00 PM and
|
|
6:37:30 PM. Pending to Alerting took 2 minutes 30 seconds, less than the
|
|
required five minutes, so the test was repeated.}{fig:sre-disk-history}
|
|
|
|
\textbf{Final threshold and versioned definition.} The restored rule uses the
|
|
required 15\% threshold (Figure~\ref{fig:sre-disk-normal}).
|
|
|
|
The final rules for both alerts were exported from Grafana as YAML and merged
|
|
into one file, which was committed to \texttt{main} through the protected
|
|
branch. After a fast-forward pull on the Droplet (\texttt{main} at
|
|
\texttt{b400750}), the pull added 75 lines to the earlier 64-line file, which
|
|
held only \texttt{ServiceUnavailable}. The added lines are the
|
|
\texttt{HostDiskLow} group (\texttt{infrastructure-alerts}). Checks run on the
|
|
Droplet on October 30, 2026:
|
|
|
|
\begin{minted}[breaklines,breakanywhere,fontsize=\small]{text}
|
|
$ git log -1 --format='%H %cI' -- monitoring/grafana/alerting/alert-rules.yaml
|
|
a482ef9ef9aac7671960a25c1d54d4a59ba2f3de 2026-10-30T23:24:14+00:00
|
|
$ grep -c HostDiskLow monitoring/grafana/alerting/alert-rules.yaml
|
|
1
|
|
$ grep -ci "discord.com/api/webhooks" monitoring/grafana/alerting/alert-rules.yaml
|
|
0
|
|
$ sha256sum monitoring/grafana/alerting/alert-rules.yaml
|
|
b87eb04d239d93ae2bd26017384c3cb92eb36a9abfb5267c7a51901c92406052
|
|
\end{minted}
|
|
|
|
\noindent The last commit that changed the file is
|
|
\texttt{a482ef9}, committed at 7:24:14 PM EDT (23:24:14 UTC). It replaced the
|
|
earlier version, whose last change was \texttt{2ab41bd} on October 29, 2026. The
|
|
committed file contains the rule titles, thresholds (below 1 and below 15),
|
|
pending periods (1 minute and 5 minutes), \emph{Alerting} no-data and error
|
|
states, and the contact-point name \texttt{team-alerts}, and it contains no
|
|
webhook URL.
|
|
\section{Incident and Recovery}
|
|
\label{sec:sre-incident}
|
|
|
|
\subsection{Exercise Plan}
|
|
The exercise stopped only the Jenkins container for about three minutes, so
|
|
that the \texttt{ServiceUnavailable} alert (Section~\ref{sec:sre-alerts}) would
|
|
fire and notify. Gitea, Caddy, and the monitoring stack were left running, and
|
|
no volume was touched. The plan was:
|
|
\begin{enumerate}
|
|
\item Announce the window to the team and confirm that no Jenkins build is
|
|
running or queued.
|
|
\item Record each action with a UTC timestamp in
|
|
\nolinkurl{/root/Scrap-Web/monitoring/incident.log}.
|
|
\item Inject the outage with \texttt{docker stop jenkins}.
|
|
\item Acknowledge the alert, then restore with \texttt{docker start jenkins}.
|
|
The command was kept ready, and the operator (\texttt{samahk13}) was to
|
|
restore early if the exercise ran long or affected other work.
|
|
\item Verify that Jenkins, the pipeline, Gitea, its webhook, and the manual
|
|
build work after recovery.
|
|
\end{enumerate}
|
|
|
|
\begin{minted}[breaklines,breakanywhere]{bash}
|
|
cd /root/Scrap-Web/monitoring
|
|
echo "$(date -Is) PRECHECK $(docker ps --filter name=jenkins --format '{{.Status}}')" | tee -a incident.log
|
|
echo "$(date -Is) INJECT docker stop jenkins" | tee -a incident.log
|
|
docker stop jenkins
|
|
echo "$(date -Is) ACK alert received in Discord, restoring" | tee -a incident.log
|
|
echo "$(date -Is) RESTORE docker start jenkins" | tee -a incident.log
|
|
docker start jenkins
|
|
echo "$(date -Is) RESOLVED notification received" | tee -a incident.log
|
|
\end{minted}
|
|
|
|
\subsection{Correlated Timeline}
|
|
All times are October 29, 2026, Eastern Daylight Time (UTC$-$4). The sources are
|
|
the operator log (\texttt{incident.log}), the raw Prometheus samples of
|
|
\texttt{probe\_success} for \nolinkurl{https://ci.ssw590-08.me/login}, the Grafana
|
|
alert-rule state history, and the Discord channel that receives the
|
|
\texttt{team-alerts} \gls{contactpoint}.
|
|
|
|
\begin{tabularx}{\linewidth}{L{1.9cm}YL{3.1cm}}
|
|
\toprule
|
|
\textbf{Time} & \textbf{Event} & \textbf{Source}\\ \midrule
|
|
4:08:42 & Last successful Jenkins probe before the outage & Prometheus sample\\
|
|
4:08:50 & Precheck: \texttt{jenkins} container ``Up 5 days'' & \texttt{incident.log}\\
|
|
\textbf{4:08:54} & \textbf{Injection:} \texttt{docker stop jenkins} & \texttt{incident.log}\\
|
|
4:09:12 & First failing probe (\texttt{probe\_success}=0) & Prometheus sample\\
|
|
4:09:40 & Rule state Normal $\rightarrow$ \textbf{Pending} & Grafana state history\\
|
|
4:10:40 & Rule state Pending $\rightarrow$ \textbf{Firing} (after the 1-minute pending period) & Grafana state history\\
|
|
4:11 & \textbf{Firing} notification for the Jenkins instance only & Discord (minute precision)\\
|
|
4:11:31 & \textbf{Acknowledged} (``ack -- Samah, restoring'') & \texttt{incident.log}, Discord\\
|
|
\textbf{4:12:29} & \textbf{Restore:} \texttt{docker start jenkins} & \texttt{incident.log}\\
|
|
4:12:42--4:13:12 & Probes still fail while Jenkins starts up & Prometheus samples\\
|
|
4:13:42 & First successful probe after the restart & Prometheus sample\\
|
|
4:14:10 & Rule state Firing $\rightarrow$ \textbf{Normal} & Grafana state history\\
|
|
4:16 & \textbf{Resolved} notification & Discord; logged 4:16:18 in \texttt{incident.log}\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\srefig{incident-probes.png}{1.0}{October 29, 2026, 4:08--4:14 PM EDT ---
|
|
\texttt{probe\_success\{job="https"\}} in Grafana Explore: the Jenkins probe
|
|
(green) is 0 from 4:09:12 to 4:13:12 PM, while the Gitea probe (yellow) stays at
|
|
1.}{fig:sre-incident-probes}
|
|
|
|
\srefig{incident-discord.png}{0.8}{October 29, 2026 --- Discord
|
|
\texttt{team-alerts} channel: Firing notification at 4:11 PM, acknowledgement at
|
|
4:11 PM, and Resolved notification at 4:16 PM. The \emph{summary} annotation
|
|
still showed the runbook URL; it was corrected afterwards.}{fig:sre-incident-discord}
|
|
|
|
\srefig{incident-state-history.png}{0.8}{October 29, 2026 --- Grafana state
|
|
history of \texttt{ServiceUnavailable} for the Jenkins instance: Pending 4:09:40,
|
|
Firing 4:10:40, Normal 4:14:10 PM.}{fig:sre-incident-history}
|
|
|
|
\subsection{Measured Detection and Restoration Times}
|
|
|
|
\begin{tabularx}{\linewidth}{L{5.0cm}L{2.0cm}Y}
|
|
\toprule
|
|
\textbf{Interval (start $\rightarrow$ end event)} & \textbf{Measured} & \textbf{Comparison with settings}\\ \midrule
|
|
Injection $\rightarrow$ first failing probe & 18 s & Expected 0--30 s (30-second scrape interval)\\
|
|
Injection $\rightarrow$ rule Pending & 46 s & Expected up to 60 s (scrape interval plus 30-second evaluation interval)\\
|
|
Injection $\rightarrow$ rule Firing & 1 min 46 s & Pending plus the 1-minute pending period, exactly as configured\\
|
|
Injection $\rightarrow$ acknowledgement & 2 min 37 s & The notification arrived after Firing plus the 30-second group wait; the operator acknowledged within the same minute\\
|
|
Restart $\rightarrow$ first successful probe & 1 min 13 s & Jenkins start-up time; the probes at 4:12:42 and 4:13:12 still failed\\
|
|
Injection $\rightarrow$ first successful probe & 4 min 48 s & Observed user-facing outage, at 30-second resolution\\
|
|
Restart $\rightarrow$ rule Normal & 1 min 41 s & First successful probe plus the next evaluation (4:14:10)\\
|
|
Rule Normal $\rightarrow$ Resolved notification & about 2 min & Held until the next group-interval send window (5 minutes after the 4:11 notification)\\
|
|
\bottomrule
|
|
\end{tabularx}
|
|
|
|
\medskip
|
|
Detection matched the configuration. The alert fired 1 minute 46 seconds after
|
|
the injection and notified within about 2--2.5 minutes, consistent with a
|
|
30-second scrape interval, a 30-second evaluation interval, a 1-minute pending
|
|
period, and a 30-second group wait. Restoration was limited by the Jenkins
|
|
start-up time rather than by the response. The Resolved message arrived about
|
|
two minutes after the rule returned to Normal, because Grafana sends further
|
|
notifications for an alert group only at the 5-minute group interval.
|
|
|
|
\subsection{Recovery and Integration Checks}
|
|
\begin{itemize}
|
|
\item \textbf{Jenkins HTTPS:} \url{https://ci.ssw590-08.me/login} loaded and
|
|
accepted login after the restart.
|
|
\item \textbf{Pipeline:} \texttt{Scrap-Web/main} run \#8, started after the
|
|
restart, passed Checkout, Syntax check, and Test.
|
|
\item \textbf{Gitea and webhook:} \url{https://git.ssw590-08.me/} stayed
|
|
available throughout (100\% of probes,
|
|
Section~\ref{sec:sre-short-window}). A \emph{Test Delivery} of the Jenkins
|
|
webhook after recovery succeeded.
|
|
\item \textbf{Manual build (not validated):} the only Gitea Actions runner
|
|
(\texttt{mac-latex-runner-new}, on a team member's laptop) was offline at the
|
|
time of the first check, unrelated to the outage. Later, Gitea Actions run
|
|
\#18 (\texttt{manual.yml}) on \texttt{main} at commit \texttt{b4007504b7}
|
|
ran for 2 minutes 2 seconds and \textbf{failed}
|
|
(Figure~\ref{fig:sre-manual-build}). Errors occurred while trying to
|
|
validate the automated manual build, and the run's log page did not load, so
|
|
the cause was not identified. No PDF artifact was downloaded, and no
|
|
successful automated build is claimed here. The re-run of commit
|
|
\texttt{3301e24} was not completed.
|
|
\end{itemize}
|
|
|
|
\srefig{manual-build-recovery.png}{0.8}{Gitea Actions run \#18 on \texttt{main}
|
|
(commit \texttt{b4007504b7}, merge of pull request \#23): failed after
|
|
2m2s.}{fig:sre-manual-build}
|
|
|
|
\subsection{Unavailable Service Versus Failed Build}
|
|
This outage differs from the failed build demonstrated in
|
|
\ChapterRef{ContinuousIntegration}
|
|
(Section~\ref{sec:ci-failure}). There, Jenkins was running and reachable. It
|
|
executed the pipeline on commit \texttt{a5180ad}, the Test stage failed, and
|
|
Jenkins reported a \emph{failure} commit status that blocked the merge until
|
|
repair commit \texttt{84a44f0} passed. That is the CI system working correctly
|
|
and rejecting bad code.
|
|
|
|
Here, no code changed and no pipeline ran. The Jenkins service itself was
|
|
unavailable: its HTTPS login page failed the \gls{probe}, no commit statuses could be
|
|
posted, and pull requests would have waited with a missing check. Monitoring,
|
|
not CI, detected it. The response was to restore the service, not to fix code.
|
|
|
|
\subsection{Blameless Review}
|
|
\begin{description}
|
|
\item[Impact:] Jenkins' web interface and CI were unavailable for about
|
|
5 minutes (4:08:54--4:13:42 PM EDT). No builds were running or queued, and no
|
|
work was lost. Gitea, Caddy, and the monitoring stack were unaffected.
|
|
\item[Cause:] A planned, deliberate \texttt{docker stop jenkins} as part of
|
|
this exercise.
|
|
\item[Detection and response:] The \texttt{ServiceUnavailable} rule fired
|
|
within its configured delay and notified Discord. The alert was acknowledged
|
|
the same minute and Jenkins was restored with one command. All recovery
|
|
checks passed, except the manual build, which waited for its runner.
|
|
\item[What went well:] Per-service alerting identified Jenkins alone; the
|
|
no-data and error policy was in place; the timeline could be reconstructed to
|
|
the second from Prometheus and the Grafana state history.
|
|
\item[Measurement gaps:]
|
|
\begin{itemize}
|
|
\item The monitoring stack runs on the same Droplet as Jenkins and Gitea. A
|
|
Droplet-wide outage would stop collection and notifications as well, so
|
|
it would go unreported.
|
|
\item Probes run from the Droplet itself, which does not prove
|
|
reachability from users' networks.
|
|
\item A successful login-page probe does not prove that builds or Git
|
|
operations work.
|
|
\item Discord shows notification times only to the minute.
|
|
\item The 5-minute group interval delayed the Resolved message by about
|
|
2 minutes.
|
|
\item The rule's \emph{summary} annotation contained the runbook URL
|
|
instead of the summary text (Figure~\ref{fig:sre-incident-discord}). It
|
|
was corrected after the exercise to
|
|
\texttt{\{\{ \$labels.instance \}\} HTTPS probe failing for 1m}.
|
|
\item The state history (Figure~\ref{fig:sre-incident-history}) also shows
|
|
an earlier false alert on October 28 (Pending 8:29:40 PM, Firing
|
|
8:30:40 PM, both services) while the probes were succeeding
|
|
(\texttt{A=1}). The threshold condition had been set up incorrectly
|
|
when the rule was created. It was corrected at 8:37:10 PM, before the
|
|
exercise. The lesson: a new rule should be checked with \emph{Preview}
|
|
against known-healthy data before it is relied on.
|
|
\item The manual-build runner depends on one laptop being online.
|
|
\end{itemize}
|
|
\end{description}
|
|
|
|
\textbf{Prioritized improvements} (Gitea issues):
|
|
\begin{enumerate}
|
|
\item \textbf{Add an external uptime check independent of the Droplet}
|
|
(\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/issues/20}{issue \#20}, owner \texttt{samahk13}). A free external HTTPS
|
|
monitor would detect a total Droplet outage that the on-Droplet stack cannot
|
|
report.
|
|
\item \textbf{Move the manual-build runner to an always-on host}
|
|
(\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/issues/21}{issue \#21}, owner \texttt{kholmes}). This removes the dependency
|
|
on a laptop for PDF builds.
|
|
\end{enumerate}
|
|
\section{Manual Integration and Traceability}
|
|
\label{sec:sre-manual}
|
|
|
|
\begin{itemize}
|
|
\item \textbf{Version and history:} this manual is Version 1.6. The
|
|
Document History has a 1.6 entry for this chapter.
|
|
\item \textbf{Hosts and Passwords tables:} the Hosts table
|
|
(Table~\ref{tab:devops-hosts}) gained rows for \texttt{metrics.ssw590-08.me}
|
|
(443, through Caddy), Grafana (\texttt{grafana:3000}, internal), Prometheus
|
|
(9090), Node Exporter (9100), and Blackbox Exporter (9115), the last three
|
|
private on the \texttt{monitoring} network, and records the two named
|
|
volumes. The Passwords table (Table~\ref{tab:devops-passwords}) gained hints
|
|
only: the Grafana \texttt{admin} password is kept in
|
|
\texttt{grafana.secrets.env} on the Droplet, and the Discord webhook URL is
|
|
stored in Grafana only.
|
|
\item \textbf{Glossary:} added \gls{sre}, \gls{sli}, \gls{sla},
|
|
\gls{errorbudget}, \gls{probe}, and \gls{contactpoint}.
|
|
\item \textbf{Citations:} the Google SRE Workbook~\cite{SREWorkbook}, the
|
|
Prometheus, Grafana, Node Exporter, and Blackbox Exporter
|
|
documentation~\cite{PrometheusDocs,GrafanaDocs,NodeExporter,BlackboxExporter,GrafanaAlerting},
|
|
and DigitalOcean's SMTP policy~\cite{DOSMTP}.
|
|
\item \textbf{AI and reuse attribution:} recorded in the AI Prompt Log
|
|
(Appendix~\ChapterRef{AIPromptLog}). The Compose file and Prometheus
|
|
configuration were adapted from the assignment's reference configuration;
|
|
the dashboard was written for this deployment.
|
|
\item \textbf{Reviewed source:} pull request
|
|
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/pulls/22}{\#22} from
|
|
\texttt{feature/issue-18-monitoring} into \texttt{main}, merged as commit
|
|
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/commit/1bfa31acc0597567e5121a802966853a38a54f1b}{\texttt{1bfa31acc0597567e5121a802966853a38a54f1b}}.
|
|
All monitoring configuration links in this chapter point to \texttt{main}
|
|
at or after this commit.
|
|
\textbf{Process deviation:} the pull request passed the required Jenkins
|
|
check but was merged by \texttt{samahk13}, using repository-administrator
|
|
rights, before \texttt{kholmes} had approved it. This bypassed the
|
|
one-approval rule on \texttt{main}. Gitea cannot approve a pull request that
|
|
is already merged, so \texttt{kholmes} reviewed the merged change afterwards
|
|
and recorded the review as a comment on pull request \#22
|
|
on October 29, 2026 at 6:43~PM EDT. To prevent a repeat, \emph{Enable push/merge
|
|
restrictions for administrators} should be turned on in the \texttt{main}
|
|
branch rule, so that the approval requirement also applies to
|
|
administrators.
|
|
\item \textbf{Automated PDF build (not validated):} no Gitea Actions run
|
|
exists for merge commit \texttt{1bfa31a}. A later run, \#18 on commit
|
|
\texttt{b4007504b7}, failed after 2 minutes 2 seconds
|
|
(Figure~\ref{fig:sre-manual-build}). There were errors while trying to
|
|
validate the automated build; the log could not be loaded and the cause was
|
|
not identified. No automated build result is claimed for this chapter.
|
|
\end{itemize}
|
|
|
|
\fussy
|