Add Prometheus/Grafana monitoring stack and Grafana route (#11)
seat-back-trivia/pipeline/head This commit looks good

Four pinned containers on a private network with memory caps for the 512 MB
droplet; provisioned data source, six-panel dashboard, HTTPS-availability and
root-disk alert rules, and the team-alerts Discord contact point. The Discord
webhook comes from the untracked grafana.secrets.env. Bring deploy/Caddyfile
in line with the droplet (ci route) and add metrics.pollefeys.dev.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cedric Pollefeys
2026-10-28 15:28:47 -04:00
co-authored by Claude Opus 5.5
parent 55ab869735
commit adb8d5fab1
10 changed files with 890 additions and 0 deletions
@@ -0,0 +1,101 @@
apiVersion: 1
# Grafana expands $NAME from its environment in provisioning files, so the
# Discord webhook comes from grafana.secrets.env and never appears in Git.
# Templates below use .Labels instead of $labels for the same reason.
contactPoints:
- orgId: 1
name: team-alerts
receivers:
- uid: team-alerts-discord
type: discord
settings:
url: $DISCORD_WEBHOOK_URL
use_discord_username: false
disableResolveMessage: false
# Every alert goes to team-alerts; one notification per rule and instance.
policies:
- orgId: 1
receiver: team-alerts
group_by: [grafana_folder, alertname, instance]
group_wait: 30s
group_interval: 1m
repeat_interval: 4h
groups:
- orgId: 1
name: https-availability
folder: Seat-Back Trivia SRE
interval: 30s
rules:
- uid: https-unavailable
title: HTTPS service unavailable
condition: C
data:
- refId: A
relativeTimeRange: {from: 300, to: 0}
datasourceUid: prometheus
model:
refId: A
expr: probe_success{job="https"}
instant: true
range: false
- refId: C
datasourceUid: __expr__
model:
refId: C
type: threshold
expression: A
conditions:
- evaluator: {type: lt, params: [1]}
# A missing probe series or a failed query is a monitoring failure,
# not health: both fire the alert.
noDataState: Alerting
execErrState: Alerting
for: 1m
labels:
severity: critical
owner: CP
annotations:
summary: "{{ .Labels.instance }} has failed its HTTPS probe for at least 1 minute."
description: "probe_success is 0, or the probe series is missing. Check the service container, Caddy, DNS, and the TLS certificate."
runbook_url: https://git.pollefeys.dev/SeatBackTrivia/devops-manual/src/branch/master/devopsMonitoring.tex
- orgId: 1
name: host-capacity
folder: Seat-Back Trivia SRE
interval: 1m
rules:
- uid: root-disk-low
title: Root filesystem below 15% free
condition: C
data:
- refId: A
relativeTimeRange: {from: 600, to: 0}
datasourceUid: prometheus
model:
refId: A
expr: node_filesystem_avail_bytes{job="node",mountpoint="/",fstype="ext4"} / node_filesystem_size_bytes{job="node",mountpoint="/",fstype="ext4"}
instant: true
range: false
- refId: C
datasourceUid: __expr__
model:
refId: C
type: threshold
expression: A
conditions:
# Free-space threshold as a fraction. The capacity test raises
# it temporarily; the final value is 0.15.
- evaluator: {type: lt, params: [0.15]}
noDataState: Alerting
execErrState: Alerting
for: 5m
labels:
severity: warning
owner: NA
annotations:
summary: "Root filesystem on ssw-590 has had less than 15% free space for 5 minutes."
description: "Check docker system df and du -sh /var/log; remove build cache and unused images, never named volumes."
runbook_url: https://git.pollefeys.dev/SeatBackTrivia/devops-manual/src/branch/master/devopsMonitoring.tex
@@ -0,0 +1,11 @@
apiVersion: 1
# The dashboard JSON in Git is the source of truth; edits in the UI are refused.
providers:
- name: seat-back-trivia
folder: Seat-Back Trivia SRE
type: file
disableDeletion: true
allowUiUpdates: false
options:
path: /etc/grafana/dashboards
@@ -0,0 +1,14 @@
apiVersion: 1
# Grafana reaches Prometheus by its service name on the monitoring network.
# localhost would mean the Grafana container itself.
datasources:
- name: Prometheus
uid: prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: false
jsonData:
timeInterval: 30s