8 Commits

Author SHA1 Message Date
kholmes a482ef9ef9 Merged rules
Scrap-Web/pipeline/pr-main Build queued...
Scrap-Web/pipeline/head This commit looks good
2026-10-30 23:24:14 +00:00
samahk13 1bfa31acc0 Merge pull request 'Feature/issue 18 monitoring' (#22) from feature/issue-18-monitoring into main
Scrap-Web/pipeline/head This commit looks good
Reviewed-on: #22
2026-10-29 22:31:33 +00:00
samahk13 2ab41bdce5 Update ServiceUnavailable alert export and runbook for #18
Scrap-Web/pipeline/pr-main This commit looks good
Scrap-Web/pipeline/head This commit looks good
2026-10-29 17:24:21 -04:00
samahk13 01f842323e Fix ServiceUnavailable threshold for #18
Scrap-Web/pipeline/head This commit looks good
2026-10-28 20:39:33 -04:00
samahk13 d6ea94f20d Add ServiceUnavailable alert export and runbook for #18
Scrap-Web/pipeline/head This commit looks good
2026-10-28 20:32:10 -04:00
samahk13 6d65f29674 Add SRE dashboard definition for #18
Scrap-Web/pipeline/head This commit looks good
2026-10-28 17:42:15 -04:00
samahk13 4c098708f4 Add monitoring stack config for #18
Scrap-Web/pipeline/head This commit looks good
2026-10-28 15:02:43 -04:00
kholmes 3301e2463e Merge pull request 'compose file addition' (#17) from kholmes-patch-3 into main
Scrap-Web/pipeline/head This commit looks good
Reviewed-on: #17
2026-10-24 08:01:55 +00:00
13 changed files with 900 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
# Pinned image versions only. No passwords in this file.
PROMETHEUS_TAG=v3.13.5
GRAFANA_TAG=13.2.5
NODE_EXPORTER_TAG=v1.12.1
BLACKBOX_TAG=v0.29.0
+2
View File
@@ -0,0 +1,2 @@
# Secrets stay on the Droplet only
grafana.secrets.env
+65
View File
@@ -0,0 +1,65 @@
# SSW 590 Monitoring Runbook
Dashboard: https://metrics.ssw590-08.me/d/ssw590-sre
Contact point: `team-alerts` (email). Times are America/New_York.
---
## ServiceUnavailable – Gitea or Jenkins HTTPS probe failing
**Owner:** samahk13 (primary), kholmes (backup)
**Severity:** critical
**Fires when:** `probe_success{job="https"}` is 0 for an instance for at least 1 minute,
or the probe series is missing (no data) / the query errors.
### 1. Acknowledge
Reply to the alert email (or post in the team chat) with "ack" and your name, and
note the time. This is the acknowledgement time in the incident timeline.
### 2. Is it the service or the monitoring?
- Open the dashboard. Check the **Scrape health (up)** row.
- `blackbox` or `https` shows DOWN / no data → the **monitoring** is broken,
not necessarily the service. Go to step 5.
- `up` is 1 but panel 4 or 5 shows DOWN → the probed request failed. Continue.
- Open the URL in a browser:
- Gitea: https://git.ssw590-08.me/user/login
- Jenkins: https://ci.ssw590-08.me/login
### 3. Check the container (SSH to the Droplet as root)
```
docker ps -a --format 'table {{.Names}}\t{{.Status}}'
docker logs --tail=50 jenkins # or: gitea
docker logs --tail=50 caddy # proxy / TLS problems
```
### 4. Restore
- Container stopped/exited:
```
docker start jenkins # or: docker start gitea
```
- Container running but unhealthy: `docker restart jenkins`
- Certificate/proxy error: check `docker logs caddy`; validate with
`docker exec caddy caddy validate --config /etc/caddy/Caddyfile`.
- **Never** use `docker compose down -v` (deletes data volumes).
Wait for the next probes (~30–60 s). The alert resolves when `probe_success` is 1
again; confirm the "Resolved" email arrives.
### 5. Monitoring itself is failing (no data / error)
```
cd /root/Scrap-Web/monitoring
docker compose ps
docker compose logs --tail=50 prometheus blackbox-exporter
docker compose start prometheus blackbox-exporter
```
### 6. After recovery
- Jenkins: run **Build Now** on `main` and confirm it passes.
- Gitea: confirm the web login and that Jenkins can still post commit statuses.
- Record the timeline in the incident issue.
---
## HostDiskLow – root filesystem below 15 % free
**Owner:** kholmes — *(partner to complete)*
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
# Step 1 baseline - run on the Droplet BEFORE starting the monitoring stack.
# Output contains no secrets; paste it into the Gitea issue.
echo "== date"; date -Is
echo "== OS"; cat /etc/os-release | head -4; uname -r
echo "== CPU"; nproc; grep -m1 "model name" /proc/cpuinfo; uname -m
echo "== memory (bytes)"; free -b
echo "== root disk"; df -B1 /; df -h /
echo "== docker"; docker version --format '{{.Server.Version}}'; docker compose version
echo "== containers"; docker ps --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}'
echo "== container usage"; docker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}'
echo "== load"; uptime
+12
View File
@@ -0,0 +1,12 @@
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
+67
View File
@@ -0,0 +1,67 @@
# SSW 590 - Monitoring stack (Prometheus, Grafana OSS, Node Exporter, Blackbox Exporter)
# Only Grafana joins gitea-net so the existing Caddy container can proxy it.
# No host ports are published; Prometheus and the exporters stay on the private network.
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]
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:
+2
View File
@@ -0,0 +1,2 @@
# Copy to grafana.secrets.env on the Droplet and fill in. Never commit the real file.
GF_SECURITY_ADMIN_PASSWORD=CHANGE_ME
@@ -0,0 +1,139 @@
apiVersion: 1
groups:
- orgId: 1
name: availability
folder: SSW 590
interval: 30s
rules:
- uid: fg2n29o6c9a80d
title: ServiceUnavailable
condition: C
data:
- refId: A
relativeTimeRange:
from: 600
to: 0
datasourceUid: prometheus
model:
editorMode: code
expr: probe_success{job="https"}
instant: true
intervalMs: 1000
legendFormat: __auto
maxDataPoints: 43200
range: false
refId: A
- refId: C
queryType: expression
datasourceUid: __expr__
model:
conditions:
- evaluator:
params:
- 1
type: lt
operator:
type: and
query:
params:
- C
reducer:
params: []
type: last
type: query
datasource:
type: __expr__
uid: __expr__
expression: A
intervalMs: 1000
maxDataPoints: 43200
refId: C
type: threshold
noDataState: Alerting
execErrState: Alerting
for: 1m
annotations:
runbook_url: https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/monitoring/RUNBOOK.md
summary: '{{ $labels.instance }} HTTPS probe failing for 1m'
labels:
owner: samahk13
severity: critical
team: ssw590
isPaused: false
notification_settings:
receiver: team-alerts
- orgId: 1
name: infrastructure-alerts
folder: SSW 590
interval: 30s
rules:
- uid: bg2tu8l6pb20wc
title: HostDiskLow
condition: C
data:
- refId: A
relativeTimeRange:
from: 600
to: 0
datasourceUid: prometheus
model:
editorMode: code
expr: |-
100 *
node_filesystem_avail_bytes{
mountpoint="/",
fstype!="rootfs",
device="/dev/vda1"
}
/
node_filesystem_size_bytes{
mountpoint="/",
fstype!="rootfs",
device="/dev/vda1"
}
instant: true
intervalMs: 1000
legendFormat: __auto
maxDataPoints: 43200
range: false
refId: A
- refId: C
queryType: expression
datasourceUid: __expr__
model:
conditions:
- evaluator:
params:
- 15
type: lt
operator:
type: and
query:
params:
- C
reducer:
params: []
type: last
type: query
datasource:
type: __expr__
uid: __expr__
expression: A
intervalMs: 1000
maxDataPoints: 43200
refId: C
type: threshold
noDataState: Alerting
execErrState: Alerting
for: 5m
annotations:
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_url: https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/monitoring/RUNBOOK.md
summary: Root filesystem free space below 15% on {{ $labels.instance }}
labels:
owner: kholmes7
severity: warning
team: ssw590
isPaused: false
notification_settings:
receiver: team-alerts
@@ -0,0 +1,547 @@
{
"uid": "ssw590-sre",
"title": "SSW 590 \u2013 Gitea & Jenkins Reliability",
"tags": [
"ssw590",
"sre"
],
"timezone": "America/New_York",
"time": {
"from": "now-6h",
"to": "now"
},
"refresh": "30s",
"schemaVersion": 39,
"version": 1,
"editable": true,
"graphTooltip": 1,
"panels": [
{
"id": 1,
"type": "timeseries",
"title": "1. Droplet CPU utilization (all CPUs)",
"description": "Percent of CPU time not idle, averaged across all CPUs over a 2-minute rate window. Whole-droplet: includes Gitea, Jenkins, Caddy and monitoring; does not attribute CPU to a container.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 0,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "100 * (1 - avg(rate(node_cpu_seconds_total{job=\"node\",mode=\"idle\"}[2m])))",
"legendFormat": "CPU busy %",
"range": true
}
],
"fieldConfig": {
"defaults": {
"unit": "percent",
"min": 0,
"max": 100,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "orange",
"value": 70
},
{
"color": "red",
"value": 90
}
]
},
"custom": {
"thresholdsStyle": {
"mode": "line"
},
"lineWidth": 2,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi"
}
}
},
{
"id": 2,
"type": "timeseries",
"title": "2. Available host memory",
"description": "MemAvailable: the kernel's estimate of memory available to start new applications without swapping (bytes, IEC). Not the same as unused RAM.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 0,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "node_memory_MemAvailable_bytes{job=\"node\"}",
"legendFormat": "MemAvailable",
"range": true
}
],
"fieldConfig": {
"defaults": {
"unit": "bytes",
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "orange",
"value": 209715200
},
{
"color": "green",
"value": 419430400
}
]
},
"custom": {
"thresholdsStyle": {
"mode": "line"
},
"lineWidth": 2,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi"
}
}
},
{
"id": 3,
"type": "timeseries",
"title": "3. Root filesystem available space (/dev/vda1)",
"description": "Available bytes divided by size bytes for the host root filesystem only (device /dev/vda1, mounted at /). Alert threshold is 15%.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 8,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "100 * node_filesystem_avail_bytes{job=\"node\",mountpoint=\"/\",device=\"/dev/vda1\"} / node_filesystem_size_bytes{job=\"node\",mountpoint=\"/\",device=\"/dev/vda1\"}",
"legendFormat": "root available %",
"range": true
}
],
"fieldConfig": {
"defaults": {
"unit": "percent",
"min": 0,
"max": 100,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "orange",
"value": 15
},
{
"color": "green",
"value": 25
}
]
},
"custom": {
"thresholdsStyle": {
"mode": "line"
},
"lineWidth": 2,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi"
}
}
},
{
"id": 4,
"type": "timeseries",
"title": "6. HTTPS probe duration",
"description": "Total time for each Blackbox HTTPS probe (DNS + connect + TLS + request, following redirects), one line per service.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 8,
"w": 12,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "probe_duration_seconds{job=\"https\"}",
"legendFormat": "{{instance}}",
"range": true
}
],
"fieldConfig": {
"defaults": {
"unit": "s",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"custom": {
"thresholdsStyle": {
"mode": "off"
},
"lineWidth": 2,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi"
}
}
},
{
"id": 5,
"type": "timeseries",
"title": "4. Gitea HTTPS availability",
"description": "1 = Blackbox Exporter's HTTPS probe of https://git.ssw590-08.me/user/login succeeded (DNS, valid TLS, 2xx after redirects); 0 = failed. Sampled every 30 s.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 16,
"w": 12,
"h": 7
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "probe_success{job=\"https\",instance=\"https://git.ssw590-08.me/user/login\"}",
"legendFormat": "{{instance}}",
"range": true
}
],
"fieldConfig": {
"defaults": {
"unit": "none",
"min": 0,
"max": 1,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "green",
"value": 1
}
]
},
"custom": {
"thresholdsStyle": {
"mode": "line"
},
"lineWidth": 2,
"fillOpacity": 10,
"drawStyle": "line",
"lineInterpolation": "stepAfter"
},
"mappings": [
{
"type": "value",
"options": {
"0": {
"text": "DOWN",
"color": "red"
},
"1": {
"text": "UP",
"color": "green"
}
}
}
],
"decimals": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi"
}
}
},
{
"id": 6,
"type": "timeseries",
"title": "5. Jenkins HTTPS availability",
"description": "1 = Blackbox Exporter's HTTPS probe of https://ci.ssw590-08.me/login succeeded (DNS, valid TLS, 2xx after redirects); 0 = failed. Sampled every 30 s.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 16,
"w": 12,
"h": 7
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "probe_success{job=\"https\",instance=\"https://ci.ssw590-08.me/login\"}",
"legendFormat": "{{instance}}",
"range": true
}
],
"fieldConfig": {
"defaults": {
"unit": "none",
"min": 0,
"max": 1,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "green",
"value": 1
}
]
},
"custom": {
"thresholdsStyle": {
"mode": "line"
},
"lineWidth": 2,
"fillOpacity": 10,
"drawStyle": "line",
"lineInterpolation": "stepAfter"
},
"mappings": [
{
"type": "value",
"options": {
"0": {
"text": "DOWN",
"color": "red"
},
"1": {
"text": "UP",
"color": "green"
}
}
}
],
"decimals": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi"
}
}
},
{
"id": 7,
"type": "stat",
"title": "Scrape health (up)",
"description": "1 = Prometheus scraped the target successfully. A target can be up while its probe_success is 0.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 23,
"w": 24,
"h": 5
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "up",
"legendFormat": "{{job}} {{instance}}",
"instant": true
}
],
"fieldConfig": {
"defaults": {
"mappings": [
{
"type": "value",
"options": {
"0": {
"text": "DOWN",
"color": "red"
},
"1": {
"text": "UP",
"color": "green"
}
}
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "green",
"value": 1
}
]
},
"unit": "none"
},
"overrides": []
},
"options": {
"colorMode": "background",
"graphMode": "none",
"textMode": "value_and_name",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
}
}
}
],
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
}
}
@@ -0,0 +1,8 @@
apiVersion: 1
providers:
- name: ssw590
folder: SSW 590
type: file
allowUiUpdates: true
options:
path: /var/lib/grafana/dashboards
@@ -0,0 +1,9 @@
apiVersion: 1
datasources:
- name: Prometheus
uid: prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: false
+32
View File
@@ -0,0 +1,32 @@
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