chapter5-monitoring #2

Merged
carmen merged 13 commits from chapter5-monitoring into main 2026-11-04 16:38:38 +00:00
8 changed files with 202 additions and 51 deletions
Showing only changes of commit 2f3040e3dc - Show all commits

View File

@ -31,13 +31,13 @@ what has been verified.
\endhead
\bottomrule
\endlastfoot
1 & Deployment and reproducibility (15) & \StatusPending & Backup procedure, restart-persistence test.\\
1 & Deployment and reproducibility (15) & \StatusPending & Restart persistence recorded (Nov.~2). Backup procedure; second verifier.\\
2 & Metrics and probes (15) & \StatusPending & Host comparison and target health recorded (Nov.~1). Team approval and reload time of the Jenkins probe exception.\\
3 & HTTPS and access control (10) & \StatusPending & Public Grafana hostname; external exposure tests.\\
4 & Dashboard and CI correlation (15) & \StatusPending & Dashboard screenshot recorded (Nov.~1). Normal-build before/during/after comparison.\\
5 & SLI, SLO, and error budget (10) & \StatusPending & Measured short-window results from the incident exercise.\\
6 & Alerts and runbooks (15) & \StatusPending & Capacity rule fired, emailed, and resolved (Nov.~1). HTTPS rule awaits the incident; recipient receipt confirmation.\\
7 & Incident and recovery (10) & \StatusPending & Entire exercise, review, and two owned improvement issues.\\
5 & SLI, SLO, and error budget (10) & \StatusPass & Definitions, worked example, and measured incident window (Nov.~2).\\
6 & Alerts and runbooks (15) & \StatusPending & Both rules fired, emailed, and resolved; receipt confirmed. Live runbook link in rule annotations.\\
7 & Incident and recovery (10) & \StatusPending & Exercise, timeline, and review recorded (Nov.~2). Owned issues 5 and 6 opened. Passing pipeline check.\\
8 & Manual integration and traceability (10) & \StatusPending & Reviewed final commit and successful automated PDF build links.\\
\end{tabularx}
@ -154,12 +154,26 @@ Grafana runtime state cannot. \StatusPending{} Document the backup procedure
for the two named volumes and the rollback compatibility check.
\subsection{Restart Persistence}
\StatusPending{} Restart Prometheus and Grafana separately without deleting
volumes. Record the restart times, then verify that earlier time-series
history, the dashboard, the data source, and both alert rules remain, and
record any collection gap. A restart test shows persistence, not a successful
\StatusPass{} After the incident on November 2, Prometheus was restarted at
16:03:58~UTC and Grafana at 16:05:12~UTC with \texttt{docker compose restart},
one at a time and without removing volumes
(\autoref{Figure:MonitoringRestart}). Afterward the dashboard loaded through
the provisioned Prometheus data source and still showed the earlier hour,
including the Jenkins outage at 15:48--15:52~UTC
(\autoref{Figure:MonitoringIncidentDashboard}). The HTTPS rule's state
history, including October 30 entries, was still present after the Grafana
restart (\autoref{Figure:MonitoringIncidentHistory}). No collection gap is
visible at the dashboard's resolution; a gap shorter than one 30-second
scrape could still exist. A restart test shows persistence, not a successful
backup restore.
\begin{figure}[htbp]\centering
\includegraphics[width=0.85\linewidth]{prism-uploads/ch5-restart-persistence.png}
\caption{Separate Prometheus and Grafana restarts with UTC timestamps,
November 2, 2026.}
\label{Figure:MonitoringRestart}
\end{figure}
\section{Metrics and Probes}
\label{sec:mon-metrics}
@ -420,19 +434,49 @@ permits: $0.01 \times 2880 = 28.8$ failed samples, or $28.8 \times 30\,\text{s}
minutes. Because samples are whole, at most 28 failures would meet the target.
\subsection{Measured Exercise Window}
\StatusPending{} After the controlled incident, record the exact window start
and end, time zone, scrape interval, and query evaluation time. Report both
services with
\StatusPass{} The measured window is the ten minutes from 15:45:00 to
15:55:00~UTC on November 2, 2026, which contains the whole Jenkins incident
(\autoref{sec:mon-incident}). The scrape interval for the \texttt{https} job
is 30 seconds. Both queries were run as instant queries in Grafana Explore,
fixed to the window end with the \texttt{@} modifier, so the evaluation time
does not depend on when they were run:
\begin{verbatim}
100 * avg_over_time(probe_success{job="https",
instance="https://ci.590hcm.dev/login"}[10m])
count_over_time(probe_success{job="https",
instance="https://ci.590hcm.dev/login"}[10m])
100 * avg_over_time(probe_success{job="https"}[10m] @ 1793634900)
count_over_time(probe_success{job="https"}[10m] @ 1793634900)
\end{verbatim}
and the equivalent Gitea queries. Compare the received count with about 20
expected samples. Missing samples are unknown and are not counted as
successes. A short window cannot establish the 24-hour SLO; full-day
evaluation is optional.
Here \texttt{1793634900} is 15:55:00~UTC on November 2, 2026.
\begin{table}[htbp]\centering\small
\begin{tabular}{L{2.2cm}L{2.0cm}L{2.0cm}L{2.0cm}L{4.0cm}}
\toprule Service & Samples received & Successes & Failures & SLI (success \%)\\\midrule
Gitea & 20 of 20 & 20 & 0 & 100\%\\
Jenkins & 20 of 20 & 11 & 9 & 55\%\\\bottomrule
\end{tabular}
\caption{Measured SLI for 15:45--15:55~UTC, November 2, 2026. Successes are
the SLI multiplied by the received count.}
\label{Table:MonitoringMeasuredSLI}
\end{table}
All 20 expected samples arrived for both services, so no sample is unknown.
Nine failed Jenkins samples at 30-second spacing equal 4.5 minutes, which
matches the measured restoration time of 4~min 18~s to 4~min 48~s
(\autoref{Table:MonitoringIncidentMeasures}).
The 55\% value describes only this ten-minute window, which was chosen
because it contains the outage; it does not measure the 24-hour SLO. For
comparison only: the daily error budget at 99\% is 28.8 failed samples
(\autoref{sec:mon-slo}), so these 9 failures would use about 31\% of one
day's budget. If every other Jenkins sample that day succeeded, the day would
end at $2871/2880 = 99.69\%$, above the target. That is a hypothetical
projection, not a measured full-day result.
\begin{figure}[htbp]\centering
\includegraphics[width=0.8\linewidth]{prism-uploads/ch5-sli-avg.png}\\[4pt]
\includegraphics[width=0.8\linewidth]{prism-uploads/ch5-sli-count.png}
\caption{Instant queries for the measured window: success percentage (top)
and received sample count (bottom).}
\label{Figure:MonitoringMeasuredSLI}
\end{figure}
\section{Alerts and Runbooks}
\label{sec:mon-alerts}
@ -526,9 +570,9 @@ Resolved email sent & 21:34 & \texttt{[RESOLVED] Root disk space below 15 percen
The firing email followed the firing state within the 30-second group wait,
and the resolved email followed recovery within the same minute. The final
provisioned setting is the original 15\% threshold. \StatusPending{} Record
the recipient's confirmation of receipt; the evidence above is from the
sender's mailbox.
provisioned setting is the original 15\% threshold. The send times above
come from the sender's mailbox; the recipient later confirmed receipt of
both emails.
\begin{figure}[htbp]\centering
\includegraphics[width=0.8\linewidth]{prism-uploads/ch5-disk-alert-firing.png}
@ -545,17 +589,21 @@ Normal 16:34:40 Eastern Standard Time (21:26:10, 21:31:10, and 21:34:40 UTC).}
\label{Figure:MonitoringDiskHistory}
\end{figure}
\paragraph{HTTPS rule.} \StatusPending{} Record firing, delivery, and
resolution for the HTTPS availability rule during the controlled Jenkins
incident in \autoref{sec:mon-incident}. Redact destination secrets
from screenshots.
\paragraph{HTTPS rule (passed).} During the controlled Jenkins incident on
November 2, the HTTPS rule went Pending at 15:48:15, fired at 15:49:15, and
sent its firing email in the 15:49 minute. It returned to Normal at 15:52:45
and sent the resolved email at 15:54~UTC. Only the Jenkins instance fired;
Gitea stayed Normal. The recipient confirmed receipt of both emails for each
rule. Full timings are in \autoref{sec:mon-incident}
(\autoref{Table:MonitoringIncident}).
\section{Incident and Recovery}
\label{sec:mon-incident}
\StatusPending{} The controlled Jenkins incident has not been run. The Jenkins
probe now succeeds; the exercise still depends on working notifications, so
the alert can be delivered and resolved.
\StatusPass{} The controlled Jenkins incident ran on November 2, 2026,
from 15:46 to 15:54~UTC. Only the Jenkins controller was stopped; Gitea,
the Jenkins agent, and monitoring stayed up. The alert recipient confirmed
receipt of both notifications.
\subsection{Exercise Plan}
Agree on a maintenance window with the team and name who restarts Jenkins.
@ -567,29 +615,91 @@ agreed duration or affects other work. Do not remove volumes or stop the
instance.
\subsection{Timeline and Measured Times}
The stop and restart used \texttt{docker stop jenkins} and
\texttt{docker start jenkins} on the host. Each command was preceded and
followed by a UTC timestamp appended to the host file
\path{~/ch5-incident.log} (\autoref{Figure:MonitoringIncidentLog}).
\begin{table}[htbp]\centering\small
\begin{tabular}{lll}
\begin{tabular}{L{3.6cm}L{2.6cm}L{6.2cm}}
\toprule Event & Time (UTC) & Source\\\midrule
Jenkins stopped & \StatusPending & incident record\\
First failing probe & \StatusPending & Prometheus\\
Alert firing & \StatusPending & Grafana\\
Notification received & \StatusPending & destination\\
Acknowledged & \StatusPending & incident record\\
Jenkins restarted & \StatusPending & incident record\\
First successful probe & \StatusPending & Prometheus\\
Resolved notification & \StatusPending & destination\\\bottomrule
Pre-check & 15:46:25 & Incident log; Jenkins availability 1.\\
Stop issued & 15:47:52 & Incident log.\\
Jenkins stopped & 15:47:57 & Incident log, after \texttt{docker stop} returned.\\
First failing probe & by 15:48:15 & Rule state history: Pending.\\
Alert firing & 15:49:15 & Rule state history: Alerting, after the one-minute pending period.\\
Notification sent & 15:49 & Sender mailbox, \texttt{[FIRING:1] HTTPS service unavailable}.\\
Notification received & confirmed & Recipient confirmed receipt; exact time not recorded.\\
Jenkins restart issued & 15:51:39 & Incident log.\\
Jenkins container started & 15:51:40 & Incident log.\\
First successful probe & 15:52:15--15:52:45 & Dashboard still 0 at 15:52:15; rule Normal at 15:52:45.\\
Alert resolved & 15:52:45 & Rule state history: Normal.\\
Resolved notification sent & 15:54 & Sender mailbox, \texttt{[RESOLVED]}.\\\bottomrule
\end{tabular}
\caption{Incident timeline. Detection time runs from the stop to the
notification; restoration time runs from the stop to the first successful
probe. Compare both with the configured scrape, evaluation, and pending
intervals.}
\caption{Incident timeline, November 2, 2026. Screens displayed Eastern
Standard Time; times are converted to UTC.}
\label{Table:MonitoringIncident}
\end{table}
\begin{table}[htbp]\centering\small
\begin{tabular}{L{4.4cm}L{2.4cm}L{5.6cm}}
\toprule Measure & Value & Explanation\\\midrule
Planned outage & 3 min 43 s & Container stopped 15:47:57, started 15:51:40.\\
Time to first failing check & $\le$ 18 s & Stop to Pending; bounded by the 30-second rule evaluation.\\
Time to firing & 78 s & Stop to Alerting: about one evaluation plus the one-minute pending period.\\
Detection (stop to notification) & about 1.5 min & Email sent in the 15:49 minute, after the 15:49:15 firing.\\
Restoration (stop to first success) & 4 min 18 s -- 4 min 48 s & Includes about one minute of Jenkins startup after the container started.\\
Restart to recovery & $\le$ 65 s & 15:51:40 to 15:52:45.\\
Recovery to resolved email & about 1--2 min & Within the five-minute group interval.\\\bottomrule
\end{tabular}
\caption{Measured detection and restoration times. Precision is limited by
the 30-second evaluation interval and minute-level email timestamps.}
\label{Table:MonitoringIncidentMeasures}
\end{table}
\begin{figure}[htbp]\centering
\includegraphics[width=0.6\linewidth]{prism-uploads/ch5-incident-log.png}
\caption{Host incident log with UTC timestamps for the stop and restart.}
\label{Figure:MonitoringIncidentLog}
\end{figure}
\begin{figure}[htbp]\centering
\includegraphics[width=0.75\linewidth]{prism-uploads/ch5-incident-firing.png}
\caption{During the incident: the HTTPS rule fires for the Jenkins instance
only, while Gitea stays Normal. Times are EST (UTC$-5$).}
\label{Figure:MonitoringIncidentFiring}
\end{figure}
\begin{figure}[htbp]\centering
\includegraphics[width=0.75\linewidth]{prism-uploads/ch5-incident-history.png}
\caption{HTTPS rule state history for the Jenkins instance, read after the
Grafana restart: Pending 10:48:15, Alerting 10:49:15, Normal 10:52:45 EST on
November 2. The October 30 entries come from setup, when the Jenkins login
returned HTTP 403 before the probe exception, and are not part of this
exercise.}
\label{Figure:MonitoringIncidentHistory}
\end{figure}
\subsection{Recovery Checks}
\StatusPending{} After recovery, verify Jenkins HTTPS and a passing pipeline,
Gitea and its webhook and commit-status integration, and the manual PDF build.
Include outage graphs from the dashboard.
After recovery, Jenkins HTTPS availability returned to 1 and stayed there,
and Gitea availability stayed at 1 throughout
(\autoref{Figure:MonitoringIncidentDashboard}). The dashboard also shows the
cost of a Jenkins start on this host: available memory rose by about
150~MiB while Jenkins was stopped, then fell to about 600~MiB, the lowest
value in the hour, during startup. CPU rose to about 10\%, and the Jenkins
probe took about 2.3~seconds while Jenkins was still starting.
\begin{figure}[htbp]\centering
\includegraphics[width=\linewidth]{prism-uploads/ch5-incident-dashboard.png}
\caption{Dashboard after the incident and the monitoring restarts, 10:06 to
11:06 EST (15:06--16:06 UTC). The Jenkins outage is visible at about
10:48--10:52 EST.}
\label{Figure:MonitoringIncidentDashboard}
\end{figure}
\StatusPending{} Run one pricing-app pipeline on \texttt{main} and record the
build number, commit, agent, start and end times, and result. Confirm the
Gitea webhook and commit status, and record the manual PDF build.
\subsection{Difference from the Chapter 4 Failure}
The Chapter 4 exercise changed application code so a test failed while
@ -598,12 +708,53 @@ removes the Jenkins service itself while the code stays correct. The first is
caught by the merge gate; the second is caught by monitoring and alerting.
\subsection{Blameless Review}
\StatusPending{} Record impact, timeline, evidence, cause, response, and
measurement gaps. Create two prioritized improvement issues in Gitea with
owners, and link them here. The review must state the shared failure domain:
monitoring runs on the same Lightsail instance as Gitea and Jenkins, so an
instance outage would also stop collection and notifications. An independent
external check should be proposed as one improvement.
This review describes what happened and what the system showed. It does not
assign blame.
\paragraph{Impact.} Jenkins could not be reached over HTTPS for about four
and a half minutes on November 2, from 15:47:57 to about 15:52:30~UTC. No
build was running, so no build was lost. Gitea, its repositories, and
monitoring were not affected.
\paragraph{Cause.} A planned stop of the Jenkins controller container for
this exercise. The code and configuration did not change.
\paragraph{Response.} The probe failure was visible within one evaluation,
the alert fired after the configured one-minute pending period, and the email
went out in the same minute. Jenkins was restarted after about 3 minutes 43
seconds, as planned. The alert resolved automatically, and the resolved email
followed within the five-minute group interval.
\paragraph{What went well.} The alert separated the two services: only the
Jenkins instance fired, and Gitea stayed Normal. No manual step was needed
to send or resolve the notification. The incident log, rule history, and
email timestamps agree with one another.
\paragraph{Measurement gaps.} Rule state times are rounded to the 30-second
evaluation interval, and the email times are rounded to the minute. The
acknowledgement time was not written down; only receipt was confirmed. The
exact first successful probe is known only to a 30-second window.
\paragraph{Shared failure domain.} Prometheus, Grafana, and the exporters run
on the same Lightsail instance as Gitea and Jenkins. If the instance itself
fails, collection and notification stop with it, and no alert would be sent.
This exercise tested a single service, not the whole host.
\paragraph{Follow-up issues.}
\begin{enumerate}
\item \textbf{High: add an independent external uptime check} for the Gitea
and Jenkins login pages from outside Lightsail, with notification to the
team, so a whole-host outage is still detected. Tracked as
\href{https://git.590hcm.dev/SSW590Team/pricing-app/issues/5}{pricing-app
issue 5}; owner \texttt{carmen}.
\item \textbf{Medium: protect memory headroom.} Jenkins startup lowered
available memory to about 600~MiB while about 800~MiB of swap was already in
use. Watch available memory during builds, consider container memory limits,
and resize the instance if builds slow down. Tracked as
\href{https://git.590hcm.dev/SSW590Team/pricing-app/issues/6}{pricing-app
issue 6}; owner \texttt{max}.
\end{enumerate}
Both issues were opened on November 2 and assigned in Gitea.
\section{Manual Integration and Traceability}
\label{sec:mon-manual}

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB