Add Prometheus/Grafana monitoring stack (refs #19)
vpn-dns-gateway/pipeline/head This commit looks good

Assignment 7 (instructor manual v1.42, Chapter 5): Prometheus, Grafana OSS,
Node Exporter and Blackbox Exporter beside Gitea/Jenkins on The-Ocean, pinned
by tag and digest, memory-capped for the 1 GiB droplet, no host ports.

- monitoring/: compose, scrape and probe config, Grafana provisioning
  (data source, Group 1 SRE dashboard, two alert rules, Discord contact
  point via env var), README with deploy/backup/rollback and runbooks,
  EVIDENCE.md with the deploy, capacity and exposure test records.
- deploy/: private probe network (172.30.90.0/28) with Caddy aliases;
  ci allowlist admits only the Blackbox address 172.30.90.10; new
  metrics.yebilly.me route behind the same allowlist.
- manual images: DNS record, Discord webhook, contact-point test, dashboard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 11:11:02 -04:00
co-authored by Claude Opus 5.5
parent 9b0dc4dc52
commit d3a5e6bc73
15 changed files with 1034 additions and 1 deletions
+9 -1
View File
@@ -10,8 +10,16 @@ colors.yebilly.me {
# Jenkins: Stevens campus network (155.246.0.0/16) plus team and approved grader # Jenkins: Stevens campus network (155.246.0.0/16) plus team and approved grader
# IPs from CI_TEAM_IPS in the untracked .env. Everyone else gets 403 before login. # IPs from CI_TEAM_IPS in the untracked .env. Everyone else gets 403 before login.
# The Stevens VPN is split-tunnel, so it does not give visitors a 155.246.x.x address. # The Stevens VPN is split-tunnel, so it does not give visitors a 155.246.x.x address.
# 172.30.90.10 is Blackbox Exporter on the private probe network (monitoring/compose.yaml).
ci.yebilly.me { ci.yebilly.me {
@denied not remote_ip 155.246.0.0/16 {$CI_TEAM_IPS} @denied not remote_ip 155.246.0.0/16 172.30.90.10/32 {$CI_TEAM_IPS}
respond @denied 403 respond @denied 403
reverse_proxy jenkins:8080 reverse_proxy jenkins:8080
} }
# Grafana (Assignment 7): same allowlist as Jenkins, then Grafana's own login.
metrics.yebilly.me {
@denied not remote_ip 155.246.0.0/16 {$CI_TEAM_IPS}
respond @denied 403
reverse_proxy grafana:3000
}
+10
View File
@@ -35,6 +35,9 @@ services:
# Jenkins resolves git.yebilly.me to Caddy here, so checkout and status # Jenkins resolves git.yebilly.me to Caddy here, so checkout and status
# calls stay on the droplet instead of hairpinning through the public IP. # calls stay on the droplet instead of hairpinning through the public IP.
aliases: [git.yebilly.me] aliases: [git.yebilly.me]
probe:
# Blackbox Exporter (monitoring/compose.yaml) probes both sites through Caddy here.
aliases: [git.yebilly.me, ci.yebilly.me]
depends_on: [gitea] depends_on: [gitea]
# Jenkins LTS controller (Assignment 6). Builds run on its single executor. # Jenkins LTS controller (Assignment 6). Builds run on its single executor.
@@ -66,3 +69,10 @@ volumes:
networks: networks:
web: web:
# Fixed subnet so Blackbox Exporter can have a fixed address (172.30.90.10), the only
# private address the ci.yebilly.me allowlist admits. The web subnet stays denied:
# Docker's proxy presents IPv6 and hairpin visitors as its gateway, 172.18.0.1.
probe:
ipam:
config:
- subnet: 172.30.90.0/28
Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

+76
View File
@@ -0,0 +1,76 @@
# Assignment 7 raw evidence (droplet The-Ocean, captured by Claude over SSH, approved by Billy)
## Baseline 2026-10-28 04:34 UTC
Ubuntu 24.04.5 LTS, kernel 6.8.0-147-generic x86_64, 1 vCPU; Docker 29.8.1, Compose v5.5.1; disk /dev/vda1 24883167232 B, 18784387072 B available (25% used); gitea_web 172.18.0.0/16; global IPv6 2604:a880:400:d1:0:5:22d:6001/64, no AAAA records; uptime 6 days, load 0.05.
Containers: gitea-jenkins-1 325.4MiB/512MiB, gitea-caddy-1 10.85MiB, gitea-gitea-1 98.21MiB. Host RSS: java 318.1, gitea 122.0, dockerd 50.0, multipathd 26.5, containerd 23.5, caddy 16.7 MiB.
```
Wed Oct 28 04:34:27 UTC 2026
total used free shared buff/cache available
Mem: 1008177152 778825728 101543936 3424256 281452544 229351424
Swap: 1073737728 479457280 594280448
Filesystem 1B-blocks Used Available Use% Mounted on
/dev/vda1 24883167232 6082015232 18784374784 25% /
NAME TYPE SIZE USED PRIO
/swapfile file 1024M 457.2M -2
gitea-jenkins-1 0.17% 326.3MiB / 512MiB
gitea-caddy-1 0.00% 11MiB / 961.5MiB
gitea-gitea-1 0.20% 102.9MiB / 961.5MiB
```
## Unused host services disabled
```
2026-10-28 04:52:51 UTC disabled+masked: multipathd(.service,.socket), fwupd(+fwupd-refresh.timer), udisks2, ModemManager
before: Mem total 1008177152 used 798810112 available 209367040
after (04:52:59): used 786944000 available 221233152 ; 04:53:0x: available 238510080, Mlocked 0
apt-daily.service ran 04:52:52-04:53:24 (40.8M peak, triggered by systemd reload); after: available 364957696, swap used 503414784
checks before change: multipath -ll empty; dmsetup ls "No devices found"; root=UUID cc6f3ac6 (/dev/vda1, LABEL cloudimg-rootfs); multipath-tools-boot not installed; initramfs multipath files 0
post: gitea-jenkins-1, gitea-caddy-1, gitea-gitea-1 Up; git login 200 1.09s, ci login 200 0.38s
undo: systemctl unmask multipathd fwupd udisks2 ModemManager && systemctl enable --now multipathd udisks2 ModemManager
```
## Image pins chosen 2026-10-28 (registry index digests)
- prom/prometheus:v3.15.1 sha256:fa3302279710be2f21a8301ec17a8b4f2301fd829bd113839b3b6b02b6f191a2 (released 2026-10-21)
- grafana/grafana:13.2.5 sha256:9f7aa1e1e3246aade5792d35a738049f7f32f89cd51d1956cf426a4e86268a84 (2026-10-27; 13.3.0 skipped as one day old)
- quay.io/prometheus/node-exporter:v1.12.1 sha256:1b4e4438faca4dd7e001dd445d161a4a2091b0fededa84093b3a8dfeae1f1be0 (2026-07-14)
- quay.io/prometheus/blackbox-exporter:v0.29.1 sha256:ea1c7aa3ef3f307cd03e85f34abb604478ccb90b567fc690da0cd9776da76b13 (2026-10-21)
## Local validation 2026-10-28 (laptop Docker 29.8.2)
- docker compose config --quiet: monitoring and deploy valid; promtool check config SUCCESS; caddy validate: Valid configuration.
- Grafana smoke run: first run rejected "{{ $$labels.instance }}" (bad character $); fixed to {{ .Labels.instance }}; rerun: both rules health ok, probes Normal from laptop, disk rule Pending (NoData) without node-exporter, dashboard group1-sre in folder SRE.
## Deploy 2026-10-28 (UTC)
- Issue #19; branch feature/issue-19-monitoring from main 9b0dc4d (Jenkins pipeline/head + Automated Manual Build success on 9b0dc4d).
- 14:40:23 second swapfile: /swapfile2 1 GiB added (fstab); swap total 2147475456 B. Disk 24883167232 B, 17710153728 B available after.
- 14:40:40 backup ~/gitea/backup-20261028T144040Z (docker-compose.yml, Caddyfile). Staged files validated on droplet (caddy validate: Valid configuration; compose config valid). Diffs = probe network + aliases; ci allowlist +172.30.90.10/32; metrics block.
- 14:40:57-14:41:09 `docker compose up -d --no-deps caddy` (recreate). gitea_probe 172.30.90.0/28; caddy gitea_probe=172.30.90.2 (aliases git/ci), gitea_web=172.18.0.3. Let's Encrypt: "certificate obtained successfully" metrics.yebilly.me. Laptop: git 200 0.049s, ci 200 0.289s, metrics 502 (Grafana not started).
- docker-proxy now targets 172.30.90.2 (probe network) for 80/443; IPv6/hairpin clients would appear as 172.30.90.1, not allowlisted (only .10/32).
- ~/monitoring copied (700). .env.secret created by Billy: 600 root; names GF_SECURITY_ADMIN_PASSWORD, DISCORD_WEBHOOK_URL; no empty values; no "$".
- 14:50:45-14:51:51 pull. promtool: SUCCESS. RepoDigests (amd64) match pins; sizes: prometheus 381400167, grafana 1949552290, node-exporter 40992821, blackbox 58273564 B. Before up: avail 241209344 B, swap used 520241152 B; disk 39% used.
- 14:52:04-14:52:08 `docker compose up -d`. Samples (avail MiB / swap used MiB): 14:52:23 228/578, 14:52:43 230/666, 14:53:02 159/668, 14:53:22 195/692, 14:53:40 211/700, 14:53:57 218/700, 14:54:14 189/705, 14:54:32 156/707. Peaks: grafana 136.6/192 MiB, prometheus 26.6/128, blackbox 15.3/32, node-exporter 13.6/32. No OOM in dmesg. Within abort limits.
- Grafana "permission denied" on /etc/grafana/provisioning/* (scp-created 700 dirs). Fix 14:55: dirs 755 / files 644 under grafana, prometheus, blackbox; restart 14:55:08; provisioning datasources, alerting, dashboards finished.
- Targets (14:5x): prometheus, node, blackbox, https x2 all up. probe_success 1 both; status 200; duration ci 0.686s, git 0.193s.
- 14:56: rules "HTTPS service down" (ci, git Normal) and "Root disk space low" (Normal), health ok; contact point team-alerts discord url set; dashboard Group 1 SRE /d/group1-sre.
- Host verification 14:56:37: root fs labels device=/dev/vda1 fstype=ext4 mountpoint=/; size 24883167232 = df; avail 15281520640 vs df 15281516544. MemTotal 1008177152 = free total; MemAvailable 293392384 vs free available 301010944 (seconds apart).
- Laptop after start: git 200 0.53s, ci 200 0.064s, metrics /login 200 1.68s, metrics /metrics 302.
## External exposure tests 2026-10-28 14:57 UTC (Billy's laptop, home network on the team allowlist, IPv6 available)
- Raw ports 3000, 3001, 8080, 9090, 9100, 9115, 50000 on 147.182.178.136 and [2604:a880:400:d1:0:5:22d:6001]: all no connection (curl 000, 5 s connect timeout).
- https://metrics.yebilly.me/metrics -> 302 to /login?redirectTo=%2Fmetrics (GF_METRICS_ENABLED=false); /api/dashboards/uid/group1-sre -> 401; /api/datasources/proxy/uid/prometheus/api/v1/query?query=up -> 401 (no anonymous access).
- https://git.yebilly.me/metrics -> 404; https://ci.yebilly.me/prometheus/ -> 403 (no app metrics endpoints).
- http://metrics.yebilly.me -> 308 to https.
- IPv6 (--resolve to droplet IPv6, no AAAA records): ci /login 403, metrics /login 403, git /user/login 200. IPv4 from allowlisted laptop: ci 200, metrics 200. Confirms docker-proxy gateway (172.30.90.1) is not allowlisted.
## Grafana login and contact-point test 2026-10-28
- ~15:01 UTC (11:01 EDT): Billy logged in at https://metrics.yebilly.me as billy; dashboard Group 1 SRE showed all 7 panels with data (screenshot).
- Contact point is provisioned, so the UI offers no Test button. Legacy POST /api/alertmanager/grafana/config/api/v1/receivers/test -> 410 Gone ("use /apis/notifications.alerting.grafana.app/v1beta1/namespaces/{namespace}/receivers/{uid}/test").
- One failed admin auth at ~15:04 UTC from the droplet host (password read from file included compose-trimmed whitespace); later calls used the container's environment.
- 15:05:55 UTC: POST .../receivers/dGVhbS1hbGVydHM/test with integration team-alerts-discord, secureFields.url=true -> {"status":"success","duration":"866ms"}.
+123
View File
@@ -0,0 +1,123 @@
# Monitoring (Assignment 7 / Instructor Manual Chapter 5)
Prometheus, Grafana OSS, Node Exporter, and Blackbox Exporter on the droplet
**The-Ocean**, beside Gitea, Jenkins, and Caddy (`deploy/`). Grafana is the only
web entry point: `https://metrics.yebilly.me` (same allowlist as Jenkins, then
Grafana login). No monitoring port is published on the host.
| Service | Image (pinned in `compose.yaml`) | Private address | Networks | Memory cap | State |
|---|---|---|---|---|---|
| Prometheus | `prom/prometheus:v3.15.1` | `prometheus:9090` | monitoring | 128 MiB | volume `monitoring_prometheus_data` (7 d / 500 MB) |
| Grafana OSS | `grafana/grafana:13.2.5` | `grafana:3000` | monitoring, `gitea_web` | 192 MiB | volume `monitoring_grafana_data` |
| Node Exporter | `quay.io/prometheus/node-exporter:v1.12.1` | `node-exporter:9100` | monitoring | 32 MiB | none (read-only host `/`) |
| Blackbox Exporter | `quay.io/prometheus/blackbox-exporter:v0.29.1` | `blackbox-exporter:9115`, `172.30.90.10` | monitoring, `gitea_probe` | 32 MiB | none |
Configuration in Git: `prometheus/prometheus.yml`, `blackbox/blackbox.yml`,
`grafana/provisioning/` (data source, dashboard provider, alert rules, contact
point), and `grafana/dashboards/sre.json`. Provisioned items are read-only in
the UI; change them here, copy to the droplet, and restart Grafana.
## Secrets (never in Git)
`~/monitoring/.env.secret` on the droplet, mode `600`, owner root:
```
GF_SECURITY_ADMIN_PASSWORD=<from the team password manager>
DISCORD_WEBHOOK_URL=<webhook for #devops-alerts>
```
The admin password applies only when Grafana first creates its database; later
changes are made in Grafana and recorded in the password manager.
## Deploy
Prerequisite: `deploy/` is current on the droplet and Caddy has been recreated
once (`cd ~/gitea && docker compose up -d caddy`), which creates the
`gitea_probe` network and the `metrics.yebilly.me` route.
```bash
scp -r monitoring root@<droplet-ip>:~/monitoring # from the laptop
cd ~/monitoring && chmod 700 .
# scp from Windows creates 700 directories; Grafana (uid 472) must read its config.
find grafana prometheus blackbox -type d -exec chmod 755 {} + && find grafana prometheus blackbox -type f -exec chmod 644 {} +
install -m 600 /dev/null .env.secret && nano .env.secret # typed by a team member
docker compose config --quiet
docker compose pull
docker compose run --rm --no-deps --entrypoint /bin/promtool prometheus check config /etc/prometheus/prometheus.yml
docker compose up -d
docker compose ps
docker compose logs --tail=50 prometheus grafana node-exporter blackbox-exporter
docker image inspect --format '{{.RepoDigests}}' prom/prometheus:v3.15.1 # repeat per image
```
Startup order does not matter: Grafana retries the data source and Prometheus
retries scrapes. All four services restart `unless-stopped`.
## Operate, update, back up, roll back
- Pause/resume: `docker compose stop` / `docker compose start`. **Never**
`docker compose down -v`; it deletes both named volumes.
- Config change: edit in Git, copy the file, then
`docker compose restart prometheus` (or `grafana`). Validate Prometheus config
with the `promtool` line above first.
- Upgrade one image at a time: back up, read the release notes, change the tag
and digest in `compose.yaml`, `docker compose pull <svc> && docker compose up -d <svc>`,
then check targets, dashboard, and alert rules. Do not assume an older Grafana
or Prometheus can read data written by a newer one: restore the backup instead.
- Contact-point test (the provisioned contact point has no Test button in the UI;
Grafana 13 removed the old test endpoint). Sends one message to `#devops-alerts`
using the stored URL, which is never printed:
```bash
GIP=$(docker inspect monitoring-grafana-1 --format '{{(index .NetworkSettings.Networks "monitoring_monitoring").IPAddress}}')
P=$(docker exec monitoring-grafana-1 printenv GF_SECURITY_ADMIN_PASSWORD)
curl -s -u "billy:$P" -H 'Content-Type: application/json' -X POST \
-d '{"integration":{"uid":"team-alerts-discord","type":"discord","version":"v1","settings":{},"secureFields":{"url":true}}}' \
"http://$GIP:3000/apis/notifications.alerting.grafana.app/v1beta1/namespaces/default/receivers/dGVhbS1hbGVydHM/test"
unset P # expect {"status":"success",...}; dGVhbS1hbGVydHM is base64 of "team-alerts"
```
- Backup (state not rebuildable from Git: Grafana users/passwords, alert state,
metric history):
```bash
cd ~/monitoring && docker compose stop grafana prometheus
docker run --rm -v monitoring_grafana_data:/g:ro -v monitoring_prometheus_data:/p:ro \
-v /root/backups:/b alpine tar czf /b/monitoring-$(date -u +%Y%m%dT%H%M%SZ).tgz /g /p
docker compose start grafana prometheus
```
- Remove the stack entirely: `docker compose stop && docker compose rm -f`
(volumes kept), then revert the `metrics` block and probe allowlist entry in
`deploy/Caddyfile` and recreate Caddy.
## Runbook: HTTPS service down
Alert `HTTPS service down` (critical, owner Billy, backup Vincent): a login
page's `probe_success` has been 0 for 1 minute, or the probe series is missing.
1. Acknowledge in `#devops-alerts` with your name and the time.
2. Open the `Group 1 SRE` dashboard. Is only one service down, or both?
- Both down, and the scrape health panel also shows failures: check Caddy and the droplet first.
- Missing data rather than 0: the monitoring stack itself is failing (`docker compose ps` in `~/monitoring`).
3. On the droplet: `cd ~/gitea && docker compose ps`, then `docker compose logs --tail=50 <gitea|jenkins|caddy>`.
4. If the service container is stopped: `docker compose start <service>`. If it
is running but unhealthy: `docker compose restart <service>`. Never use
`down -v`.
5. Confirm the probe returns to 1 and Discord shows the resolved message. For
Jenkins, also run a pipeline and confirm the Gitea status check.
6. Record the timeline in the incident log or manual.
## Runbook: Root disk space low
Alert `Root disk space low` (warning, owner Billy): available space on `/`
(`/dev/vda1`, ext4) has stayed below 15% for 5 minutes. 15% of 24.9 GB is
about 3.7 GB: enough to act before Gitea, Jenkins, or Prometheus fail to write.
1. Acknowledge in `#devops-alerts`.
2. `df -h /` and `docker system df` to find the growth.
3. Safe first actions: `docker builder prune` (build cache), `journalctl --vacuum-size=200M`,
remove obsolete images with `docker image prune`. Do not delete volumes.
4. Prometheus is capped at 500 MB / 7 days; if it is the cause, lower the cap
rather than deleting its volume.
5. If space cannot be recovered, plan a disk resize (permanent, costs more) with the team.
+14
View File
@@ -0,0 +1,14 @@
# Success = DNS answer, valid certificate for the hostname, redirects followed,
# and a final 2xx on the login page. TLS verification stays on.
modules:
http_2xx:
prober: http
timeout: 10s
http:
method: GET
preferred_ip_protocol: ip4
valid_status_codes: [] # empty = any 2xx
follow_redirects: true
fail_if_not_ssl: true
tls_config:
insecure_skip_verify: false
+96
View File
@@ -0,0 +1,96 @@
# Monitoring stack on The-Ocean (Assignment 7 / Instructor Manual Chapter 5).
# Four project-published images, pinned by tag and digest (the repository ignores
# .env files, so versions live here). No service publishes a host port:
# Caddy reaches grafana:3000 on gitea_web; Prometheus and the exporters stay on
# the private "monitoring" network. Pause with stop/start; never "down -v".
name: monitoring
services:
prometheus:
image: prom/prometheus:v3.15.1@sha256:fa3302279710be2f21a8301ec17a8b4f2301fd829bd113839b3b6b02b6f191a2
restart: unless-stopped
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
- --storage.tsdb.retention.time=7d
- --storage.tsdb.retention.size=500MB # whichever limit is hit first
environment:
- GOMEMLIMIT=96MiB # Go GC target below the container cap
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
networks: [monitoring]
mem_limit: 128m
grafana:
image: grafana/grafana:13.2.5@sha256:9f7aa1e1e3246aade5792d35a738049f7f32f89cd51d1956cf426a4e86268a84
restart: unless-stopped
# Root-only, untracked: GF_SECURITY_ADMIN_PASSWORD and DISCORD_WEBHOOK_URL (see README).
env_file: [.env.secret]
environment:
GF_SERVER_ROOT_URL: https://metrics.yebilly.me/
GF_SECURITY_ADMIN_USER: billy
GF_SECURITY_COOKIE_SECURE: "true"
GF_SECURITY_DISABLE_GRAVATAR: "true"
GF_AUTH_ANONYMOUS_ENABLED: "false"
GF_USERS_ALLOW_SIGN_UP: "false"
GF_METRICS_ENABLED: "false" # no public /metrics through the HTTPS hostname
# 1 GiB droplet: skip plugin downloads, news, and phone-home checks.
GF_PLUGINS_PREINSTALL_DISABLED: "true"
GF_NEWS_NEWS_FEED_ENABLED: "false"
GF_ANALYTICS_REPORTING_ENABLED: "false"
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
GF_ANALYTICS_CHECK_FOR_PLUGIN_UPDATES: "false"
GOMEMLIMIT: 150MiB
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning:ro
- ./grafana/dashboards:/var/lib/grafana-dashboards:ro
networks: [monitoring, web]
mem_limit: 192m
node-exporter:
image: quay.io/prometheus/node-exporter:v1.12.1@sha256:1b4e4438faca4dd7e001dd445d161a4a2091b0fededa84093b3a8dfeae1f1be0
restart: unless-stopped
pid: host
command:
- --path.rootfs=/host
- --path.procfs=/host/proc
- --path.sysfs=/host/sys
# Only what the dashboard and alerts use: CPU, memory, root disk.
- --collector.disable-defaults
- --collector.cpu
- --collector.meminfo
- --collector.filesystem
- --collector.loadavg
- --collector.uname
volumes:
- /:/host:ro,rslave # read-only host view; no Docker socket, not privileged
networks: [monitoring]
mem_limit: 32m
blackbox-exporter:
image: quay.io/prometheus/blackbox-exporter:v0.29.1@sha256:ea1c7aa3ef3f307cd03e85f34abb604478ccb90b567fc690da0cd9776da76b13
restart: unless-stopped
command: ["--config.file=/config/blackbox.yml"]
volumes:
- ./blackbox/blackbox.yml:/config/blackbox.yml:ro
networks:
monitoring:
probe:
# The only private address allowed past the ci.yebilly.me allowlist.
ipv4_address: 172.30.90.10
mem_limit: 32m
networks:
monitoring:
web:
external: true
name: gitea_web
probe:
external: true
name: gitea_probe # defined in deploy/docker-compose.yml; Caddy answers git/ci there
volumes:
prometheus_data:
grafana_data:
+569
View File
@@ -0,0 +1,569 @@
{
"uid": "group1-sre",
"title": "Group 1 SRE",
"tags": [
"sre",
"assignment7"
],
"timezone": "America/New_York",
"refresh": "30s",
"time": {
"from": "now-6h",
"to": "now"
},
"schemaVersion": 41,
"version": 1,
"editable": false,
"graphTooltip": 1,
"panels": [
{
"id": 1,
"type": "timeseries",
"title": "Droplet CPU utilization (%)",
"description": "Whole-droplet CPU busy %, averaged across CPUs: 100 minus the idle-time rate over 2m. Counts every workload on the host, not one container.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 0,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "percent",
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"lineInterpolation": "linear",
"thresholdsStyle": {
"mode": "line"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"min": 0,
"max": 100
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "100 * (1 - avg(rate(node_cpu_seconds_total{job=\"node\",mode=\"idle\"}[2m])))",
"legendFormat": "CPU busy"
}
]
},
{
"id": 2,
"type": "timeseries",
"title": "Available memory (bytes)",
"description": "MemAvailable: the kernel's estimate of memory available to start new applications without swapping (not just unused RAM).",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 0,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "bytes",
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"lineInterpolation": "linear",
"thresholdsStyle": {
"mode": "line"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "green",
"value": 104857600
}
]
},
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "node_memory_MemAvailable_bytes{job=\"node\"}",
"legendFormat": "available"
}
]
},
{
"id": 3,
"type": "timeseries",
"title": "Root filesystem available (%)",
"description": "Available bytes / size bytes for the host root filesystem (/dev/vda1, ext4, mounted at /). Alert fires below 15% for 5m.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 8,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "percent",
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"lineInterpolation": "linear",
"thresholdsStyle": {
"mode": "line"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "green",
"value": 15
}
]
},
"min": 0,
"max": 100
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "100 * node_filesystem_avail_bytes{job=\"node\",mountpoint=\"/\",fstype=\"ext4\"} / node_filesystem_size_bytes{job=\"node\",mountpoint=\"/\",fstype=\"ext4\"}",
"legendFormat": "/ available"
}
]
},
{
"id": 4,
"type": "timeseries",
"title": "Gitea HTTPS availability (probe_success)",
"description": "1 = Blackbox Exporter fetched the Gitea login page with valid TLS and a 2xx; 0 = the probe failed.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 8,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "none",
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"lineInterpolation": "stepAfter",
"thresholdsStyle": {
"mode": "off"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"min": 0,
"max": 1,
"mappings": [
{
"type": "value",
"options": {
"0": {
"text": "DOWN",
"color": "red"
},
"1": {
"text": "UP",
"color": "green"
}
}
}
]
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "probe_success{job=\"https\",instance=\"https://git.yebilly.me/user/login\"}",
"legendFormat": "Gitea"
}
]
},
{
"id": 5,
"type": "timeseries",
"title": "Jenkins HTTPS availability (probe_success)",
"description": "1 = Blackbox Exporter fetched the Jenkins login page with valid TLS and a 2xx; 0 = the probe failed.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 16,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "none",
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"lineInterpolation": "stepAfter",
"thresholdsStyle": {
"mode": "off"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"min": 0,
"max": 1,
"mappings": [
{
"type": "value",
"options": {
"0": {
"text": "DOWN",
"color": "red"
},
"1": {
"text": "UP",
"color": "green"
}
}
}
]
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "probe_success{job=\"https\",instance=\"https://ci.yebilly.me/login\"}",
"legendFormat": "Jenkins"
}
]
},
{
"id": 6,
"type": "timeseries",
"title": "HTTPS probe duration (s)",
"description": "Total time of each probe (DNS, connect, TLS, request), one line per service.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 16,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "s",
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"lineInterpolation": "linear",
"thresholdsStyle": {
"mode": "off"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "probe_duration_seconds{job=\"https\",instance=\"https://git.yebilly.me/user/login\"}",
"legendFormat": "Gitea"
},
{
"refId": "B",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "probe_duration_seconds{job=\"https\",instance=\"https://ci.yebilly.me/login\"}",
"legendFormat": "Jenkins"
}
]
},
{
"id": 7,
"type": "timeseries",
"title": "Scrape health (up)",
"description": "Optional: 1 = Prometheus scraped the target. For the https job, up=1 can coexist with probe_success=0 (collection worked, the probed request failed).",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 24,
"w": 24,
"h": 6
},
"fieldConfig": {
"defaults": {
"unit": "none",
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 10,
"showPoints": "never",
"lineInterpolation": "stepAfter",
"thresholdsStyle": {
"mode": "off"
}
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"min": 0,
"max": 1,
"mappings": [
{
"type": "value",
"options": {
"0": {
"text": "DOWN",
"color": "red"
},
"1": {
"text": "UP",
"color": "green"
}
}
}
]
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "up",
"legendFormat": "{{job}} {{instance}}"
}
]
}
],
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
}
}
@@ -0,0 +1,88 @@
# Grafana-managed alerts. Grafana expands $VAR in the contact point, which keeps the
# webhook URL out of Git; templates use .Labels instead of $labels to avoid "$".
apiVersion: 1
contactPoints:
- orgId: 1
name: team-alerts
receivers:
- uid: team-alerts-discord
type: discord
settings:
url: $DISCORD_WEBHOOK_URL # from the untracked .env.secret
disableResolveMessage: false # resolved notifications on
groups:
- orgId: 1
name: sre
folder: SRE
interval: 30s # matches the scrape interval
rules:
- uid: https-service-down
title: HTTPS service down
condition: C
data:
- refId: A
relativeTimeRange: {from: 300, to: 0}
datasourceUid: prometheus
model:
refId: A
expr: probe_success{job="https"}
instant: true
- refId: C
datasourceUid: __expr__
model:
refId: C
type: threshold
expression: A
conditions:
- evaluator: {type: lt, params: [1]}
for: 1m
# A missing series or a failed query is a monitoring failure, not health.
noDataState: Alerting
execErrState: Error
labels: {severity: critical, owner: billy}
annotations:
summary: "{{ .Labels.instance }} HTTPS probe is failing"
description: "probe_success has been 0 for at least 1 minute. Owner: Billy (backup: Vincent)."
runbook_url: https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring/README.md#runbook-https-service-down
notification_settings:
receiver: team-alerts
group_by: [alertname, instance]
group_wait: 10s
group_interval: 1m
repeat_interval: 4h
- uid: root-disk-low
title: Root disk space low
condition: C
data:
- refId: A
relativeTimeRange: {from: 300, to: 0}
datasourceUid: prometheus
model:
refId: A
expr: 100 * node_filesystem_avail_bytes{job="node",mountpoint="/",fstype="ext4"} / node_filesystem_size_bytes{job="node",mountpoint="/",fstype="ext4"}
instant: true
- refId: C
datasourceUid: __expr__
model:
refId: C
type: threshold
expression: A
conditions:
- evaluator: {type: lt, params: [15]}
for: 5m
noDataState: Alerting
execErrState: Error
labels: {severity: warning, owner: billy}
annotations:
summary: "Root filesystem on The-Ocean below 15% free"
description: "Available space on / has stayed under 15% for 5 minutes. Owner: Billy (backup: Vincent)."
runbook_url: https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring/README.md#runbook-root-disk-space-low
notification_settings:
receiver: team-alerts
group_by: [alertname]
group_wait: 10s
group_interval: 1m
repeat_interval: 4h
@@ -0,0 +1,8 @@
apiVersion: 1
providers:
- name: sre
folder: SRE
type: file
allowUiUpdates: false # Git is the source of truth for the dashboard
options:
path: /var/lib/grafana-dashboards
@@ -0,0 +1,11 @@
apiVersion: 1
datasources:
- name: Prometheus
uid: prometheus
type: prometheus
access: proxy
url: http://prometheus:9090 # service name; localhost would be the Grafana container
isDefault: true
editable: false
jsonData:
timeInterval: 30s
+30
View File
@@ -0,0 +1,30 @@
global:
scrape_interval: 30s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ["prometheus:9090"]
- job_name: node
static_configs:
- targets: ["node-exporter:9100"]
- job_name: blackbox
static_configs:
- targets: ["blackbox-exporter:9115"]
# Multi-target pattern: each URL becomes the probe target and the instance label;
# the scrape itself goes to Blackbox Exporter's /probe endpoint.
- job_name: https
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets:
- https://git.yebilly.me/user/login
- https://ci.yebilly.me/login
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: blackbox-exporter:9115