Sync vault notes: April-November 2026 sessions, projects, and architecture
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fe4fe656be
commit
994c7ae577
379 files changed
+55216
-107
No files matched your search
@@ -0,0 +1,112 @@
|
||||
# FetcherPay public subdomains Traefik outage restoration
|
||||
|
||||
**Date:** 2026-06-17
|
||||
**Status:** Resolved
|
||||
**Healthy ratio before:** mixed 502/000/self-signed across `*.fetcherpay.com`
|
||||
**Healthy ratio after:** 18/18 Prometheus blackbox probes up
|
||||
|
||||
## Symptom
|
||||
After a Traefik outage and container churn, public FetcherPay/SquareMCP subdomains were returning:
|
||||
- `502` for `fetcherpay.com`, `www.fetcherpay.com`, `mail.fetcherpay.com`, `workflow.fetcherpay.com`
|
||||
- `000`/no route for `docs.fetcherpay.com`, `sandbox.fetcherpay.com`, `obsidian-sync.fetcherpay.com`, `mail.squaremcp.com`
|
||||
- Self-signed certificate for `workflow.fetcherpay.com`
|
||||
- `chat.fetcherpay.com` (Flowise) was crash-looping due to slow startup vs. probes
|
||||
|
||||
## Root causes
|
||||
1. `fetcherpay-api` healthcheck used `localhost:3000`, which resolved to IPv6 and failed while the server bound IPv4.
|
||||
2. `docker-compose.fetcherpay.yml` environment variables (`API_HOST`, `WEB_HOST`, `GITEA_HOST`, etc.) were not set, so Docker-provider Traefik labels generated invalid `Host(``)` routers and the entire Docker dynamic config was rejected.
|
||||
3. Traefik file-provider (`/home/garfield/letsencrypt/manual/tls.yml`) had stale Docker IPs for `fetcherpay-web` (pointed at MySQL) and `temporal-ui` (pointed at `fetcherpay-api`).
|
||||
4. Several public subdomains had no Traefik router at all.
|
||||
5. There were duplicate Docker and K8s services; public traffic was accidentally routed to Docker leftovers instead of the intended K8s deployments.
|
||||
|
||||
## Fix steps
|
||||
1. Fixed `fetcherpay-api` healthcheck to use `127.0.0.1:3000` in `docker-compose.fetcherpay.yml`.
|
||||
2. Disabled Traefik Docker provider in `/home/garfield/traefik.yml` so invalid compose labels would not break dynamic config loading.
|
||||
3. Rewrote `/home/garfield/letsencrypt/manual/tls.yml`:
|
||||
- Replaced stale Docker IPs with service names or K8s ClusterIPs.
|
||||
- Added missing routers/services for `obsidian`, `docs`, `sandbox`, `dashboard`, `obsidian-sync`, `chat`, `mail.squaremcp.com`, `api.fetcherpay.com`.
|
||||
- Set `certResolver: letsencrypt` for domains that needed new certificates.
|
||||
4. Connected the `obsidian` container to the `fetcherpay_fetcherpay` network and updated `/home/garfield/obsidian/docker-compose.yml` so the connection persists across restarts.
|
||||
5. Restarted Traefik and waited for Let’s Encrypt DNS challenges to propagate.
|
||||
6. Stopped redundant Docker duplicates: `fetcherpay-web`, `gitea`, `temporal`, `temporal-ui`, `grafana`, `prometheus`, `adminer`.
|
||||
|
||||
## Final architecture
|
||||
- **Edge proxy:** Docker `traefik` on `art0` ports 80/443.
|
||||
- **Public apps:** routed to **K8s services** in namespace `fetcherpay`.
|
||||
- **Still in Docker because no K8s equivalent exists:**
|
||||
- `obsidian` → `obsidian.fetcherpay.com`
|
||||
- `poste` → `mail.fetcherpay.com`, `mail.squaremcp.com`
|
||||
- `fetcherpay-api` → `api.fetcherpay.com`
|
||||
- backing DBs for the above: Docker `postgres`, `mysql`, `redis`
|
||||
|
||||
## Verification
|
||||
```bash
|
||||
# All blackbox probes up
|
||||
curl -sS 'http://10.152.183.123:9090/api/v1/query?query=sum(probe_success)'
|
||||
# 18/18
|
||||
```
|
||||
|
||||
Spot-check (valid TLS, no `-k`):
|
||||
- https://fetcherpay.com → 200
|
||||
- https://git.fetcherpay.com → 200
|
||||
- https://workflow.fetcherpay.com → 200
|
||||
- https://dashboard.fetcherpay.com → 302 → 200
|
||||
- https://docs.fetcherpay.com → 200
|
||||
- https://sandbox.fetcherpay.com → 200
|
||||
- https://chat.fetcherpay.com → 200
|
||||
- https://obsidian.fetcherpay.com → 200
|
||||
- https://obsidian-sync.fetcherpay.com → 200
|
||||
- https://mail.squaremcp.com → 302 → 200
|
||||
|
||||
## Dashboards
|
||||
- Traefik: http://localhost:8080/dashboard/
|
||||
- Grafana: https://dashboard.fetcherpay.com
|
||||
- Prometheus: http://10.152.183.123:9090
|
||||
|
||||
## How to avoid this again
|
||||
1. **Source of truth for public routing is `/home/garfield/letsencrypt/manual/tls.yml`.** Update it when adding/removing subdomains; do not rely on Docker labels until the compose env vars are restored.
|
||||
2. **Use K8s service ClusterIPs, not Docker container IPs**, because Docker IPs change on recreate.
|
||||
3. **Do not run duplicate Docker stacks** for services that already exist in K8s (`fetcherpay-web`, `gitea`, `temporal`, `grafana`, `prometheus`).
|
||||
4. **Healthchecks should use `127.0.0.1` instead of `localhost`** in Alpine-based containers to avoid IPv6 ambiguity.
|
||||
5. **Missing `.env` file:** `/home/garfield/docker-compose.fetcherpay.yml` requires `API_HOST`, `WEB_HOST`, `GITEA_HOST`, `MAIL_HOST`, `GRAFANA_HOST`, `PROM_HOST`, `ADMINER_HOST`, `TEMPORAL_HOST`, plus DB credentials. Restore this file before re-enabling the Traefik Docker provider or recreating the Docker stack.
|
||||
|
||||
## Remaining work
|
||||
- Migrate `fetcherpay-api` and `poste` into K8s if the goal is Docker-free except Obsidian.
|
||||
- Restore the missing `.env` for the FetcherPay Docker stack so the remaining Docker apps have valid DB credentials.
|
||||
|
||||
## Artifact locations (added after resolution)
|
||||
|
||||
- **Server infrastructure repo:** `https://git.fetcherpay.com/garfield/fetcherpay-infra.git` (working copy `/home/garfield/fetcherpay-infra`)
|
||||
- Tracks `traefik.yml`, `tls.yml`, `traefik-compose.yml`, `docker-compose.fetcherpay.yml`, `obsidian/docker-compose.yml`, etc.
|
||||
- `.env` and live certs are gitignored.
|
||||
- **Server-wide agent context:** `/home/garfield/AGENTS.md` and `/home/garfield/.kimi/AGENTS.md`
|
||||
- **Project agent context:** `/home/garfield/hermes-mcp/CLAUDE.md`
|
||||
|
||||
## Follow-up fix: Grafana health dropped back to 0.944
|
||||
|
||||
**Cause:** `hermes.squaremcp.com/health` began failing because the `hermes-mcp` K8s pod uses `hostNetwork: true` and expects MySQL on `127.0.0.1:3306`. The Docker MySQL container was not exposing port 3306 to the host, so the pod got `ECONNREFUSED`.
|
||||
|
||||
**Fix:**
|
||||
1. Added `127.0.0.1:3306:3306` port mapping to the `mysql` service in `docker-compose.fetcherpay.yml`.
|
||||
2. Recreated the MySQL container.
|
||||
3. Force-deleted the `hermes-mcp` pod so the deployment recreated it on a host where MySQL was reachable.
|
||||
|
||||
**Verification:** `sum(probe_success) == 18 / 18`, and `https://hermes.squaremcp.com/health` returns 200.
|
||||
|
||||
## Follow-up: dashboard crash and low pods-running ratio
|
||||
|
||||
**Symptom:** Grafana dashboard became unreachable and the "pods running ratio" panel dropped.
|
||||
|
||||
**Root cause:** The cluster was unstable — many pods were stuck in `ContainerCreating`/`ImagePullBackOff` because pulls from `localhost:32000` (microk8s registry) were timing out or getting connection refused. The Grafana pod itself was among those restarting. Additionally, long-broken `fetcherpay-leads-api` and `fetcherpay-leads-worker` deployments (image missing for ~260 days) plus completed debug pods were dragging the ratio down.
|
||||
|
||||
**Fix:**
|
||||
1. Waited for registry pulls to complete and pods to settle.
|
||||
2. Deleted completed debug pods in `fetcherpay`.
|
||||
3. Scaled `fetcherpay-leads-api` and `fetcherpay-leads-worker` deployments to `0` replicas (they have been failing for months and appear unused).
|
||||
|
||||
**Verification:**
|
||||
- `kubectl get pods --all-namespaces --field-selector=status.phase!=Running` → `No resources found`
|
||||
- `https://dashboard.fetcherpay.com` → 302 (Grafana login)
|
||||
- Prometheus `probe_success` → 18/18
|
||||
|
||||
**Note:** If `fetcherpay-leads-api` / `fetcherpay-leads-worker` are still needed, they need a valid image in `localhost:32000` or a registry fix.
|
||||
@@ -0,0 +1,70 @@
|
||||
# obsidian.fetcherpay.com 502 fix
|
||||
|
||||
**Date:** 2026-06-17
|
||||
**Status:** Resolved
|
||||
**Healthy ratio before:** 0.944 (17/18)
|
||||
**Healthy ratio after:** 1.000 (18/18)
|
||||
|
||||
## Symptom
|
||||
|
||||
Prometheus Blackbox Exporter showed only **0.944** of monitored websites as healthy. Probe identified one failing target:
|
||||
|
||||
```
|
||||
❌ FAIL 502 https://obsidian.fetcherpay.com
|
||||
```
|
||||
|
||||
## Root cause
|
||||
|
||||
`obsidian.fetcherpay.com` routes through the Docker **Traefik** edge proxy (which owns public ports 80/443) to the `obsidian` container on host port `8082`. The container was stopped, so Traefik returned `502 Bad Gateway`.
|
||||
|
||||
Relevant config:
|
||||
|
||||
- `/home/garfield/obsidian/docker-compose.yml` — Obsidian Remote container, port `8082:8080`
|
||||
- `/home/garfield/obsidian-k8s.yaml` — K8s mirror (currently bypassed by Traefik)
|
||||
- `/home/garfield/letsencrypt/manual/tls.yml` — Traefik dynamic routing for other domains; Obsidian router comes from Docker labels
|
||||
|
||||
## Fix
|
||||
|
||||
Started the Obsidian container:
|
||||
|
||||
```bash
|
||||
cd /home/garfield/obsidian
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
The container needed ~30–45 seconds to initialize (xrdp, timezone, etc.). After that, the backend began responding on `localhost:8082` and public HTTPS returned `200 OK`.
|
||||
|
||||
## Verification
|
||||
|
||||
```bash
|
||||
# Direct backend
|
||||
curl -I http://localhost:8082/
|
||||
# HTTP/1.1 200 OK
|
||||
|
||||
# Public edge
|
||||
curl -I https://obsidian.fetcherpay.com/
|
||||
# HTTP/2 200
|
||||
```
|
||||
|
||||
Full site probe after fix:
|
||||
|
||||
```
|
||||
Total: 18 pass, 0 fail
|
||||
Healthy ratio: 1.000
|
||||
```
|
||||
|
||||
Prometheus `avg(probe_success{job="blackbox-http"})` returned to **1.0** on the next scrape.
|
||||
|
||||
## Notes
|
||||
|
||||
- Port 8082 was free before starting the container; no port conflicts.
|
||||
- Blackbox Exporter was working correctly — it accurately detected the one down target.
|
||||
- K8s nginx-ingress is still bypassed for public traffic; the Docker/Traefik path is what matters for this domain.
|
||||
|
||||
## Related files
|
||||
|
||||
- `/home/garfield/obsidian/docker-compose.yml`
|
||||
- `/home/garfield/obsidian-k8s.yaml`
|
||||
- `/home/garfield/traefik-compose.yml`
|
||||
- `/home/garfield/hermes-mcp/monitoring/prometheus-config.yaml`
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
date: 2026-09-15
|
||||
tags: [art0, security, watchdog, tailscale, infrastructure, runbook]
|
||||
status: active-monitor-only
|
||||
---
|
||||
# art0 security watchdog: Tailscale-safe bans and restart preparation
|
||||
|
||||
## Earlier decision and status (superseded below)
|
||||
The watchdog and daily SSH report remain suspended in garfield's crontab, verified again when this runbook was written. The dedicated SNAT persistence service is enabled and active. The watchdog was neither run nor re-enabled during the review or changes.
|
||||
|
||||
Recommendation: re-enable the existing five-minute watchdog after explicit user authorization, and verify the first completed run alongside downstream connectivity. Its Slack/email alerts are part of normal operation; running the watchdog is not a read-only test. No live ban or notification test has been performed. The daily report is a separate job and should be explicitly included in any restart instruction.
|
||||
|
||||
## Why these changes were necessary
|
||||
There were separate networking problems:
|
||||
1. On art0, legacy Calico forwarding cleared bits in Tailscale's packet mark. This stopped Tailscale's marked masquerade rule from matching. An explicit source/interface SNAT rule restored the exit node. Watchdog suspension alone did not fix this.
|
||||
2. The watchdog's previous automatic SSH bans rejected **all protocols** from an offending public IP. Three matching failed-login log lines within 24 hours could cause a full source ban, potentially blocking the UDP transport of a direct Tailscale connection from the same public IP. The new rule limits new bans to the actual SSH listener, **TCP/2222**, while retaining the 100.64.0.0/10 tailnet exclusion.
|
||||
3. The later Mac/Nexxt outage after a Mac restart involved a changed tunnel interface and incorrect local return routing. That is separate from the watchdog and was addressed in the linked Mac runbook.
|
||||
|
||||
The new watchdog helper inserts:
|
||||
```sh
|
||||
iptables -I INPUT 1 -s "$ip" -p tcp --dport 2222 -m comment --comment security-watchdog-ssh -j REJECT --reject-with tcp-reset
|
||||
```
|
||||
Ban detection was also adjusted to ignore unrelated port/protocol bans while still recognizing pre-existing broad bans. Historical broad bans were not removed or narrowed. Legitimate failed public SSH logins can still trigger an SSH ban; the change prevents such a new ban from also blocking Tailscale UDP.
|
||||
|
||||
## Original schedules (still commented out)
|
||||
- Every five minutes: `/home/garfield/hermes-mcp/scripts/security-watchdog.sh`
|
||||
- Daily at 08:00 in the cron scheduler's timezone: `/home/garfield/hermes-mcp/scripts/security-watchdog-daily-report.sh`
|
||||
|
||||
Restore only the intended commented entries when authorized; preserve all unrelated cron jobs. Do not infer UTC from the schedule without checking the server/cron timezone.
|
||||
|
||||
## Re-enable validation checklist
|
||||
- Confirm only the intended cron entries were restored and no duplicate schedules were introduced.
|
||||
- Observe the first scheduled watchdog run and completion in `/home/garfield/security-watchdog.log`; the script uses a lock to avoid overlap.
|
||||
- Confirm any newly inserted watchdog ban is TCP/2222 only.
|
||||
- Check that the single explicit SNAT rule remains present and passes traffic.
|
||||
- Test a phone or Windows device on **coralsprings**, with any device-local VPN and cellular fallback disabled: exact expected IPv4 **104.190.60.129**.
|
||||
- If a regression occurs, suspend only the restored watchdog entries and investigate. Do not flush the firewall or remove the SNAT workaround.
|
||||
|
||||
## Deployment record and rollback
|
||||
# art0 Tailscale exit SNAT persistence — 2026-09-15
|
||||
|
||||
Calico's legacy forwarding chain clears bits used by Tailscale's NAT mark. Explicit IPv4 source NAT for 100.64.0.0/10 through enp2s0 restores exit-node forwarding.
|
||||
|
||||
## Installed
|
||||
- tailscale-exit-snat.sh → /usr/local/sbin/tailscale-exit-snat (root-owned, 0755).
|
||||
- tailscale-exit-snat.service → /etc/systemd/system/; enabled and started.
|
||||
- tailscaled-exit-snat.conf → /etc/systemd/system/tailscaled.service.d/exit-snat.conf.
|
||||
- Added the matching rule to the existing *nat section of /etc/iptables/rules.v4 without replacing other saved rules.
|
||||
|
||||
The helper locks and checks for the rule before inserting it. The oneshot runs after network-online, netfilter-persistent, and tailscaled at boot. ExecStartPost runs it after future Tailscale daemon starts. No daemon restart or reboot was performed during installation.
|
||||
|
||||
## Watchdog
|
||||
/home/garfield/hermes-mcp/scripts/security-watchdog.sh now adds only TCP destination-port 2222 bans, with comment security-watchdog-ssh and tcp-reset rejection. Tailnet exclusion remains. Ban detection ignores unrelated protocol/port bans. Existing broad bans were retained. Both watchdog cron entries remain suspended; the watchdog itself was not executed.
|
||||
|
||||
## Validation
|
||||
Shell syntax, existing ban-detection regression, and mocked SSH-only/tailnet-exclusion checks passed. iptables-restore --test accepted the updated saved file. systemd-analyze verify passed. Running the helper twice left one live matching rule. Service enabled/active, daemon hook loaded, saved rule present. Mac public IPv4 remained 104.190.60.129. A real reboot/restart recovery test remains outstanding.
|
||||
|
||||
## Backups and rollback
|
||||
- Watchdog: /home/garfield/security-watchdog-backup-20260915-032939/security-watchdog.sh
|
||||
- Saved firewall: /root/tailscale-snat-persistence-20260915-033030/rules.v4
|
||||
|
||||
To undo persistence, disable tailscale-exit-snat.service, remove only its installed unit/helper and the exit-snat.conf drop-in, restore the saved rules backup after checking for subsequent changes, and daemon-reload. Disabling this oneshot does not remove the live NAT rule. Removing the live NAT rule would break the workaround; do so only deliberately. Restoring the watchdog backup restores broad future bans. Do not re-enable watchdog cron as part of rollback.
|
||||
|
||||
The Mac's separate PF sharing fix is still temporary; this change only makes the art0 NAT workaround persistent.
|
||||
|
||||
## Related notes
|
||||
- [[2026-09-14-mac-nexxt-tailscale-art0-sharing]] — full session history, Mac PF scripts, return-route recovery, and coralsprings tests.
|
||||
|
||||
Changes are present in the remote working copies and installed system files. No git commit or push was performed. This runbook records configured persistence; an actual art0 reboot/restart recovery test remains outstanding.
|
||||
|
||||
## Superseding decision: monitoring only, no automatic bans
|
||||
|
||||
User authorized resuming monitoring with **no automatic banning** while travelling in Jamaica. On September 15 the live watchdog was changed so `check_and_ban_ssh_attackers` logs monitor-only mode and returns without scanning or banning; `ban_ssh_ip` refuses action; `iptables_save` refuses writes; and `iptables_cmd` accepts only the exact read-only `-S INPUT` request. These are code-level restrictions, not environment-variable defaults. Existing bans were retained.
|
||||
|
||||
Mocked tests confirmed that the disabled entry points cannot invoke iptables or Docker and that firewall-write requests are rejected. Existing ban-detection regression and shell syntax passed. Daily report source was reviewed: its firewall access is read-only. A live monitoring cycle is being validated before schedules resume. Backup: `/home/garfield/watchdog-monitor-only-20260915-035701/` (watchdog script and crontab).
|
||||
|
||||
Earlier recommendations in this note to resume SSH auto-bans are superseded. Restoring an older script backup would reintroduce banning logic and must not be done without authorization.
|
||||
|
||||
### Confirmed activation — monitor-only
|
||||
The live monitoring cycle completed successfully at 03:59:15 server time, logging both "Automatic banning disabled; monitoring and alerts only" and "All checks passed." INPUT firewall rules had the identical SHA-256 before and after: `d7474a758fbd6aa693304c715fd43b46d59a12f491ea1d74cf47e7da65657218`.
|
||||
|
||||
The five-minute watchdog and daily 08:00 report cron entries were then restored and read back for verification. **Monitoring and scheduled reporting are active; automatic banning and firewall saving in this watchdog are disabled.** Existing firewall bans remain. The Mac still returned public IPv4 **104.190.60.129**. No new phone/Windows end-to-end test was performed during activation.
|
||||
@@ -0,0 +1,174 @@
|
||||
---
|
||||
date: 2026-09-16
|
||||
status: verified-temporary
|
||||
tags: [networking, tailscale, globalprotect, macos, runbook]
|
||||
---
|
||||
|
||||
# Windows GlobalProtect over Mac → Nexxt → art0
|
||||
|
||||
## Verified result
|
||||
|
||||
GlobalProtect changed from IPSec to **SSL** after a narrow Mac firewall adjustment. The user's Windows screenshot showed a working IPLeak page, GlobalProtect connected to US Southeast using SSL, and public IPv4 **144.125.117.20**. This is the corporate VPN exit address, so Windows should not be expected to display art0's 104.190.60.129 while routed through GlobalProtect. This was a successful browsing test, not a comprehensive leak or application test.
|
||||
|
||||
No passwords or credentials are included in this runbook or its script copies. Enter the Mac administrator password interactively when sudo requests it. Windows administrator access was not required.
|
||||
|
||||
## Topology and prerequisite configuration
|
||||
|
||||
Windows → Nexxt Wi-Fi **coralsprings** → Nexxt WAN 192.168.2.2 → Mac Ethernet/bridge100 192.168.2.1 → Tailscale utun5 → art0 exit → corporate GlobalProtect gateway → internet.
|
||||
|
||||
- Windows Wi-Fi was 192.168.5.94, gateway 192.168.5.1.
|
||||
- Mac USB Ethernet service AX88179A, device en8, belongs to bridge100.
|
||||
- Mac Tailscale address 100.115.106.53; art0 100.115.252.53, public 104.190.60.129.
|
||||
- Existing Mac sharing NAT and route-to rules must already work; see [[2026-09-14-mac-nexxt-tailscale-art0-sharing]].
|
||||
- Mac route to 192.168.2.2 must use bridge100; Tailscale Allow LAN Access was enabled during the earlier recovery.
|
||||
|
||||
## Why the change was made
|
||||
|
||||
The phone could browse through coralsprings, but Windows with GlobalProtect connected could not complete HTTPS. DNS resolved and TCP 443 connectivity testing succeeded. Curl stalled during connection/TLS setup. Windows DF pings to 1.1.1.1 with 1,200-byte payloads all timed out; 1,000-byte payloads all succeeded. The Mac Tailscale interface MTU was 1280. This strongly indicated a packet-size/fragmentation problem with nested VPNs; the exact dropping hop was not established.
|
||||
|
||||
Windows was managed without local administrator access. GlobalProtect Preferences did not offer a user-selectable SSL option. Instead, a temporary Mac rule blocked only UDP 4501 from the Nexxt WAN address to the observed GlobalProtect gateways. GlobalProtect successfully used its supported SSL fallback on TCP 443. Corporate VPN authentication and policy enforcement remained in GlobalProtect.
|
||||
|
||||
## Exact change
|
||||
|
||||
Anchor: `com.apple.internet-sharing/shared_v4`. Insert these before the existing quick pass/route-to rule, after scrub and NAT declarations:
|
||||
|
||||
```pf
|
||||
block drop in quick on bridge100 inet proto udp from 192.168.2.2 to 144.125.117.20 port 4501
|
||||
block drop in quick on bridge100 inet proto udp from 192.168.2.2 to 140.209.215.174 port 4501
|
||||
```
|
||||
|
||||
The initial gateway was **140.209.215.174** (US South). GlobalProtect subsequently chose **144.125.117.20** (US Southeast), explaining why the first rule did not resolve the problem. Adding the second gateway and removing its existing PF states enabled SSL fallback. No broad UDP block was added.
|
||||
|
||||
Existing NAT, scrub/MSS 1240, routing, and IPv6-blocking rules were preserved. Do not merely lower TCP MSS expecting it to change TCP already encrypted inside an IPSec tunnel.
|
||||
|
||||
## Scripts and backups
|
||||
|
||||
Local Mac scripts:
|
||||
|
||||
- `/Users/garfieldheron/NetworkTools/test-globalprotect-ssl.sh`: initial test; snapshots the current anchor, validates configurations, adds the first gateway, clears its states. Stops if its backup directory already exists.
|
||||
- `/Users/garfieldheron/NetworkTools/add-globalprotect-gateway.sh`: snapshots the live anchor, adds the second gateway, validates and applies it, clears only router-to-gateway states.
|
||||
|
||||
Root-owned backups:
|
||||
|
||||
- `/var/root/coralsprings-globalprotect-ssl-test/before.conf`: configuration before either test block.
|
||||
- `/var/root/globalprotect-gateway.lNUWxQ/before.conf`: configuration before adding the second gateway (first block already present).
|
||||
|
||||
Exact script copies are appended below for reference. They contain no credentials. Do not repeatedly run the add-gateway script: it does not deduplicate rules.
|
||||
|
||||
## Check or recover
|
||||
|
||||
1. Confirm Mac Tailscale is using art0 and ordinary browsing through coralsprings works.
|
||||
2. Inspect the current anchor on the Mac:
|
||||
|
||||
```sh
|
||||
sudo pfctl -a com.apple.internet-sharing/shared_v4 -sr
|
||||
sudo pfctl -a com.apple.internet-sharing/shared_v4 -sn
|
||||
route -n get 192.168.2.2
|
||||
```
|
||||
|
||||
3. In Windows GlobalProtect → Connections, check the gateway address and protocol. Reconnect after the test is applied. Verify **SSL**, then browse IBM or IPLeak.
|
||||
4. If a different gateway is selected, the two existing rules do not cover it. Confirm the new address before adjusting the narrow rule; preserve current sharing rules and take a fresh backup.
|
||||
5. If Internet Sharing or a reboot replaces the PF rules, restore the underlying sharing setup first. Interface names and DHCP addresses can change. Do not blindly replay stale utun5/192.168.2.2 rules. The initial script intentionally refuses to overwrite its previous backup.
|
||||
|
||||
## Undo
|
||||
|
||||
To remove both test blocks by restoring the pre-test anchor:
|
||||
|
||||
```sh
|
||||
sudo /bin/sh /Users/garfieldheron/NetworkTools/test-globalprotect-ssl.sh undo
|
||||
```
|
||||
|
||||
Then reconnect GlobalProtect. The undo script clears states to the original gateway only; reconnecting closes the newer gateway session. Restoring this snapshot also restores all other anchor settings from that time, so compare with current rules first if further sharing changes have been made.
|
||||
|
||||
To undo only the second addition, use its `before.conf` after comparison and syntax validation. Do not flush the entire Mac firewall or replace `/etc/pf.conf`.
|
||||
|
||||
## Limitations
|
||||
|
||||
This is a temporary live PF adjustment, not an installed startup service. Rebooting or toggling Internet Sharing may remove it. Corporate gateway selection may change. SSL fallback availability is controlled by the corporate VPN configuration and was confirmed for the observed US Southeast connection. No durable reconnect/startup automation was installed.
|
||||
|
||||
The art0 watchdog is separately **active in monitor-only mode**, with automatic bans disabled. See [[2026-09-15-art0-watchdog-tailscale-safety]].
|
||||
|
||||
## Vendor reference
|
||||
|
||||
[Palo Alto: GlobalProtect ports](https://docs.paloaltonetworks.com/ngfw/administration/firewall-administration/reference-port-number-usage/ports-used-for-globalprotect): UDP 4501 for IPSec, TCP 443 for SSL tunnels.
|
||||
|
||||
## Script snapshot: test-globalprotect-ssl.sh
|
||||
|
||||
```sh
|
||||
#!/bin/sh
|
||||
# Temporary, gateway-specific GlobalProtect SSL fallback test.
|
||||
set -eu
|
||||
PATH=/usr/bin:/bin:/usr/sbin:/sbin
|
||||
A=com.apple.internet-sharing/shared_v4
|
||||
B=/var/root/coralsprings-globalprotect-ssl-test
|
||||
GW=140.209.215.174
|
||||
[ "$(id -u)" = 0 ] || { echo 'Run this script with sudo on the Mac.'; exit 1; }
|
||||
if [ "${1:-}" = undo ]; then
|
||||
pfctl -n -a "$A" -f "$B/before.conf"
|
||||
pfctl -a "$A" -f "$B/before.conf"
|
||||
pfctl -k 192.168.2.2 -k "$GW" || true
|
||||
echo 'Previous sharing rules restored. Reconnect GlobalProtect.'
|
||||
exit
|
||||
fi
|
||||
[ ! -e "$B" ] || { echo 'A test backup already exists. Stop and return to Codex.'; exit 1; }
|
||||
ifconfig utun5 | grep -q 'inet 100.115.106.53 ' || { echo 'Tailscale interface changed; stop.'; exit 1; }
|
||||
ifconfig bridge100 | grep -q 'inet 192.168.2.1 ' || { echo 'Sharing network changed; stop.'; exit 1; }
|
||||
umask 077
|
||||
mkdir "$B"
|
||||
pfctl -a "$A" -sr > "$B/filter.txt"
|
||||
pfctl -a "$A" -sn > "$B/nat.txt"
|
||||
grep -q 'route-to utun5' "$B/filter.txt" || { echo 'Expected sharing route missing; stop.'; exit 1; }
|
||||
grep -q 'nat on utun5' "$B/nat.txt" || { echo 'Expected NAT missing; stop.'; exit 1; }
|
||||
{
|
||||
grep '^scrub' "$B/filter.txt" || true
|
||||
cat "$B/nat.txt"
|
||||
grep -v '^scrub' "$B/filter.txt"
|
||||
} > "$B/before.conf"
|
||||
{
|
||||
grep '^scrub' "$B/filter.txt" || true
|
||||
cat "$B/nat.txt"
|
||||
echo "block drop in quick on bridge100 inet proto udp from 192.168.2.2 to $GW port 4501"
|
||||
grep -v '^scrub' "$B/filter.txt"
|
||||
} > "$B/test.conf"
|
||||
pfctl -n -a "$A" -f "$B/before.conf"
|
||||
pfctl -n -a "$A" -f "$B/test.conf"
|
||||
if ! pfctl -a "$A" -f "$B/test.conf"; then
|
||||
pfctl -a "$A" -f "$B/before.conf"
|
||||
exit 1
|
||||
fi
|
||||
# Remove only this router's sessions to the corporate gateway.
|
||||
pfctl -k 192.168.2.2 -k "$GW" || true
|
||||
pfctl -a "$A" -sr
|
||||
echo 'Test active. Reconnect GlobalProtect on Windows; check for Protocol: SSL.'
|
||||
echo 'If it fails, undo on the Mac:'
|
||||
echo 'sudo /bin/sh /Users/garfieldheron/NetworkTools/test-globalprotect-ssl.sh undo'
|
||||
|
||||
```
|
||||
|
||||
## Script snapshot: add-globalprotect-gateway.sh
|
||||
|
||||
```sh
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
PATH=/usr/bin:/bin:/usr/sbin:/sbin
|
||||
[ "$(id -u)" = 0 ] || exit 1
|
||||
A=com.apple.internet-sharing/shared_v4
|
||||
umask 077
|
||||
B=$(mktemp -d /var/root/globalprotect-gateway.XXXXXX)
|
||||
pfctl -a "$A" -sr > "$B/filter"
|
||||
pfctl -a "$A" -sn > "$B/nat"
|
||||
grep -q 'to 140.209.215.174 port = 4501' "$B/filter"
|
||||
grep -q 'route-to utun5' "$B/filter"
|
||||
{ grep '^scrub' "$B/filter" || true; cat "$B/nat"; grep -v '^scrub' "$B/filter"; } > "$B/before.conf"
|
||||
{ grep '^scrub' "$B/filter" || true; cat "$B/nat"; echo 'block drop in quick on bridge100 inet proto udp from 192.168.2.2 to 144.125.117.20 port 4501'; grep -v '^scrub' "$B/filter"; } > "$B/after.conf"
|
||||
pfctl -n -a "$A" -f "$B/before.conf"
|
||||
pfctl -n -a "$A" -f "$B/after.conf"
|
||||
if ! pfctl -a "$A" -f "$B/after.conf"; then
|
||||
pfctl -a "$A" -f "$B/before.conf"
|
||||
exit 1
|
||||
fi
|
||||
pfctl -k 192.168.2.2 -k 144.125.117.20
|
||||
pfctl -a "$A" -sr
|
||||
echo "Backup: $B/before.conf"
|
||||
|
||||
```
|
||||
@@ -0,0 +1,87 @@
|
||||
# Observability Runbook Index
|
||||
|
||||
**Folder:** `SquareMCP/runbooks/observability/`
|
||||
**Cluster:** `art0` (single-node MicroK8s)
|
||||
**Grafana:** https://dashboard.fetcherpay.com
|
||||
**Login:** `admin` / `admin_secure_2024`
|
||||
|
||||
---
|
||||
|
||||
## What this folder covers
|
||||
|
||||
Operational documentation for monitoring, logging, tracing, and alerting across FetcherPay and SquareMCP. This includes everything added or fixed in the 2026-06-16 monitoring session:
|
||||
|
||||
- OpenTelemetry Collector (traces, logs, metrics)
|
||||
- FetcherPay Prometheus + remote-write receiver
|
||||
- Redis exporter (new)
|
||||
- Loki / Tempo operational dashboards
|
||||
- Comprehensive health overview dashboard
|
||||
- Alertmanager email + Slack routing
|
||||
- Known unhealthy services and their root causes
|
||||
|
||||
---
|
||||
|
||||
## Quick links
|
||||
|
||||
| Resource | URL / Location |
|
||||
|----------|----------------|
|
||||
| Main health dashboard | https://dashboard.fetcherpay.com/d/fetcherpay-health-overview/fetcherpay-squaremcp-e28094-health-overview |
|
||||
| Loki Operational | https://dashboard.fetcherpay.com/d/MQHVDmtWk/loki-operational |
|
||||
| Tempo Operational | https://dashboard.fetcherpay.com/d/5BcHdkRgz/tempo-operational |
|
||||
| Blackbox Exporter | imported dashboard in Grafana |
|
||||
| MySQL Overview | imported dashboard in Grafana |
|
||||
| Node Exporter Full | imported dashboard in Grafana |
|
||||
| K8s cluster | imported dashboard in Grafana |
|
||||
|
||||
---
|
||||
|
||||
## Files in this runbook
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `01-monitoring-architecture.md` | What is monitored, by what, and where the data lives |
|
||||
| `02-dashboards-and-queries.md` | Dashboard inventory + reusable PromQL queries |
|
||||
| `03-api-reference.md` | How to query Prometheus/Loki/Tempo/Grafana via API |
|
||||
| `04-alerts-and-response.md` | Alert routes, what they mean, and how to respond |
|
||||
| `05-ai-agent-guide.md` | How an AI agent should use this observability stack |
|
||||
| `06-human-guide.md` | How a human uses Grafana day-to-day |
|
||||
| `07-known-issues.md` | Pre-existing unhealthy services and why |
|
||||
|
||||
---
|
||||
|
||||
## One-line status commands
|
||||
|
||||
```bash
|
||||
# Cluster overview
|
||||
microk8s kubectl get nodes
|
||||
microk8s kubectl get pods -n fetcherpay
|
||||
microk8s kubectl get pods -n observability
|
||||
|
||||
# Core observability health
|
||||
microk8s kubectl get pods -n observability -l app=otel-collector
|
||||
microk8s kubectl get pods -n fetcherpay -l app=prometheus
|
||||
microk8s kubectl get pods -n observability -l app.kubernetes.io/name=grafana
|
||||
|
||||
# Quick Prometheus query (FetcherPay)
|
||||
curl -u admin:admin_secure_2024 \
|
||||
'https://dashboard.fetcherpay.com/api/datasources/proxy/uid/ffpaxh13af2f4e/api/v1/query?query=up'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Datasource UIDs (for API use)
|
||||
|
||||
| Datasource | UID | Type |
|
||||
|------------|-----|------|
|
||||
| Prometheus (FetcherPay) | `ffpaxh13af2f4e` | prometheus |
|
||||
| Prometheus (K8s Observability) | `ffpaxh1q3zo5cc` | prometheus |
|
||||
| Loki | `afpb0s2gdn6yoc` | loki |
|
||||
| Tempo | `efpb0sa7zs0e8f` | tempo |
|
||||
| Alertmanager | `afpb0sgrf7hmoa` | alertmanager |
|
||||
|
||||
---
|
||||
|
||||
## Related vault notes
|
||||
|
||||
- Phase 1 Communications deploy handoff: `SquareMCP/deployments/2026-06-15-phase1-communications-deploy-handoff.md`
|
||||
- Monitoring deploy session: `SquareMCP/deployments/2026-06-16-otel-collector-remote-write-loki-tempo-dashboards.md`
|
||||
@@ -0,0 +1,113 @@
|
||||
# Monitoring Architecture
|
||||
|
||||
**Stack:** Prometheus + Grafana + Loki + Tempo + Alertmanager + OpenTelemetry Collector
|
||||
**Cluster:** single-node MicroK8s on `art0`
|
||||
**Namespaces:**
|
||||
- `fetcherpay` — app workloads and custom Prometheus/blackbox/MySQL/Redis exporters
|
||||
- `observability` — kube-prometheus-stack (Grafana, K8s Prometheus, Loki, Tempo, Alertmanager, node-exporter, kube-state-metrics)
|
||||
|
||||
---
|
||||
|
||||
## Data flow
|
||||
|
||||
```
|
||||
Applications / Websites / Host
|
||||
│
|
||||
├──► Blackbox exporter ──► FetcherPay Prometheus
|
||||
├──► MySQL exporter ─────► FetcherPay Prometheus
|
||||
├──► Redis exporter ─────► FetcherPay Prometheus
|
||||
├──► OTel Collector ─────► FetcherPay Prometheus (remote write)
|
||||
│ │
|
||||
│ ├── metrics dashboards
|
||||
│ └── Alertmanager rules
|
||||
│
|
||||
├──► OTel Collector ─────► Tempo (traces)
|
||||
└──► OTel Collector ─────► Loki (logs)
|
||||
|
||||
Kube-prometheus-stack (observability namespace)
|
||||
│
|
||||
├──► K8s Prometheus ─────► Grafana + Alertmanager
|
||||
├──► node-exporter ─────► K8s Prometheus
|
||||
└──► kube-state-metrics ─► K8s Prometheus
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## What is monitored where
|
||||
|
||||
### FetcherPay Prometheus (`prometheus.fetcherpay:9090`)
|
||||
|
||||
| Job | Source | Metrics |
|
||||
|-----|--------|---------|
|
||||
| `prometheus` | itself | Prometheus health / remote-write stats |
|
||||
| `blackbox-http` | 18 HTTPS endpoints | `probe_success`, `probe_duration_seconds`, SSL expiry |
|
||||
| `mysql` | host MySQL via `mysql-exporter:9104` | `mysql_*` connections, queries, replication |
|
||||
| `redis` | Redis via `redis-exporter:9121` | `redis_*` memory, clients, hit ratio |
|
||||
| `node-exporter` | K8s node-exporter | CPU / memory / disk / network (duplicates K8s prom) |
|
||||
| `kube-state-metrics` | K8s kube-state-metrics | cluster-level pod/deployment/service state |
|
||||
| `otel-collector` | OTel collector self-metrics | `otelcol_*` exporter throughput, queue size |
|
||||
|
||||
### K8s Observability Prometheus (`kube-prom-stack-kube-prome-prometheus.observability:9090`)
|
||||
|
||||
| Job | Source | Metrics |
|
||||
|-----|--------|---------|
|
||||
| `kubernetes-apiservers` | API server | K8s control plane |
|
||||
| `kubernetes-cAdvisor` | kubelet | container resource usage |
|
||||
| `kubernetes-nodes` | kubelet | node metrics |
|
||||
| `kubernetes-pods` | pod service discovery | any pod with prometheus.io annotations |
|
||||
| `kube-state-metrics` | kube-state-metrics | object state |
|
||||
| `node-exporter` | node-exporter | hardware/OS metrics |
|
||||
|
||||
### Loki (`loki.observability:3100`)
|
||||
|
||||
- Receives logs via OTel Collector `otlp_http/loki` exporter.
|
||||
- Labels: `cluster`, `job`, `namespace`, `pod`, `container` (when available).
|
||||
|
||||
### Tempo (`tempo.observability:4317` gRPC, `3100` HTTP)
|
||||
|
||||
- Receives traces via OTel Collector `otlp_grpc/tempo` exporter.
|
||||
- Supports Jaeger/Zipkin/OTLP receivers on the collector.
|
||||
|
||||
---
|
||||
|
||||
## Kubernetes manifests
|
||||
|
||||
All manifests live in `hermes-mcp/monitoring/`:
|
||||
|
||||
| File | Deploys |
|
||||
|------|---------|
|
||||
| `opentelemetry-collector.yaml` | OTel collector Deployment/ConfigMap/Service in `observability` |
|
||||
| `prometheus-deployment.yaml` | FetcherPay Prometheus Deployment in `fetcherpay` |
|
||||
| `prometheus-config.yaml` | ConfigMap mounted into FetcherPay Prometheus |
|
||||
| `blackbox-exporter.yaml` | Blackbox exporter in `fetcherpay` |
|
||||
| `mysql-exporter.yaml` | MySQL exporter (hostNetwork) in `fetcherpay` |
|
||||
| `redis-exporter.yaml` | Redis exporter in `fetcherpay` |
|
||||
| `grafana-deployment.yaml` | Custom Grafana with SMTP env vars |
|
||||
| `alertmanager-config.yaml` | Alertmanager config (email + Slack) |
|
||||
|
||||
---
|
||||
|
||||
## Networking and ports
|
||||
|
||||
| Service | Namespace | Ports | Notes |
|
||||
|---------|-----------|-------|-------|
|
||||
| `prometheus` | `fetcherpay` | 9090 | ClusterIP; remote-write enabled |
|
||||
| `blackbox-exporter` | `fetcherpay` | 9115 | ClusterIP |
|
||||
| `mysql-exporter` | `fetcherpay` | 9104 | ClusterIP; uses `hostNetwork: true` to reach host MySQL |
|
||||
| `redis-exporter` | `fetcherpay` | 9121 | ClusterIP |
|
||||
| `otel-collector` | `observability` | 4317, 4318, 14250, 14268, 9411, 8888 | OTLP/Jaeger/Zipkin/metrics |
|
||||
| `kube-prom-stack-grafana` | `observability` | 3000 | ClusterIP; exposed via ingress |
|
||||
| `kube-prom-stack-kube-prome-prometheus` | `observability` | 9090 | ClusterIP |
|
||||
| `loki` | `observability` | 3100 | ClusterIP |
|
||||
| `tempo` | `observability` | 3100, 4317 | ClusterIP |
|
||||
| `nginx-ingress-microk8s` | `ingress` | 80, 443, 10254 | `hostNetwork: true` edge router |
|
||||
|
||||
---
|
||||
|
||||
## Notes for AI agents
|
||||
|
||||
- FetcherPay Prometheus is the source of truth for custom app/site/infrastructure health.
|
||||
- K8s Prometheus is the source of truth for cluster/node/container metrics.
|
||||
- Grafana dashboards can pull from both; the health overview dashboard uses both.
|
||||
- Loki/Tempo are fed by the OTel collector, not directly by apps.
|
||||
- The `kubelet` TLS cert on `art0` does not include `104.190.60.129`, so `kubectl exec`, `port-forward`, and `logs` may fail. Use `--insecure-skip-tls-verify-backend=true` for logs, or `kubectl proxy` for HTTP health checks.
|
||||
@@ -0,0 +1,192 @@
|
||||
# Dashboards and Queries
|
||||
|
||||
**Grafana:** https://dashboard.fetcherpay.com
|
||||
**Login:** `admin` / `admin_secure_2024`
|
||||
|
||||
---
|
||||
|
||||
## Dashboard inventory
|
||||
|
||||
### Custom / session-built dashboards
|
||||
|
||||
| Dashboard | URL | Purpose |
|
||||
|-----------|-----|---------|
|
||||
| **FetcherPay / SquareMCP — Health Overview** | `/d/fetcherpay-health-overview/fetcherpay-squaremcp-e28094-health-overview` | All websites, K8s pods, DB/cache, infra health in one place |
|
||||
| **Loki Operational** | `/d/MQHVDmtWk/loki-operational` | Loki ingest/query performance |
|
||||
| **Tempo Operational** | `/d/5BcHdkRgz/tempo-operational` | Tempo trace ingest/query performance |
|
||||
|
||||
### Imported dashboards (kube-prometheus-stack + grafana.com)
|
||||
|
||||
| Dashboard | Source | Purpose |
|
||||
|-----------|--------|---------|
|
||||
| Blackbox Exporter | grafana.com | HTTPS endpoint probes |
|
||||
| MySQL Overview | grafana.com | MySQL performance |
|
||||
| Node Exporter Full | grafana.com | Linux node metrics |
|
||||
| Kubernetes cluster | kube-prometheus-stack | K8s cluster overview |
|
||||
| Kubernetes cluster monitoring | kube-prometheus-stack | K8s workload monitoring |
|
||||
|
||||
---
|
||||
|
||||
## How to create or edit a dashboard
|
||||
|
||||
### Human workflow
|
||||
|
||||
1. Log in to Grafana.
|
||||
2. Click **+ → Dashboard** or open an existing dashboard and click the gear for **Settings**.
|
||||
3. Add a panel. Choose the datasource:
|
||||
- **Prometheus (FetcherPay)** for app/site/DB metrics
|
||||
- **Prometheus (K8s Observability)** for cluster/node metrics
|
||||
- **Loki** for logs
|
||||
- **Tempo** for traces
|
||||
4. Write the query (see reusable queries below).
|
||||
5. Save. Give it a clear title, tag it (`health`, `squaremcp`, `fetcherpay`), and pick a folder.
|
||||
|
||||
### AI-agent workflow (API)
|
||||
|
||||
Use the Grafana API to import/export dashboards. See `03-api-reference.md` for full examples.
|
||||
|
||||
Quick import from a dashboard JSON file:
|
||||
|
||||
```bash
|
||||
curl -u admin:admin_secure_2024 \
|
||||
-X POST https://dashboard.fetcherpay.com/api/dashboards/db \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d @dashboard.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Reusable PromQL queries
|
||||
|
||||
### Websites / external endpoints
|
||||
|
||||
```promql
|
||||
# All sites up/down (1 = up)
|
||||
probe_success{job="blackbox-http"}
|
||||
|
||||
# Percentage of healthy sites
|
||||
avg(probe_success{job="blackbox-http"}) * 100
|
||||
|
||||
# Response time
|
||||
probe_duration_seconds{job="blackbox-http"}
|
||||
|
||||
# SSL certificate days remaining
|
||||
(probe_ssl_earliest_cert_expiry{job="blackbox-http"} - time()) / 86400
|
||||
```
|
||||
|
||||
### Infrastructure services
|
||||
|
||||
```promql
|
||||
# Up/down for all infra exporters
|
||||
up{job=~"mysql|redis|node-exporter|kube-state-metrics|prometheus|otel-collector"}
|
||||
|
||||
# Combined single table (infra + websites)
|
||||
label_replace(
|
||||
up{job=~"mysql|redis|node-exporter|kube-state-metrics|prometheus|otel-collector"},
|
||||
"server", "$1", "instance", "(.+)"
|
||||
)
|
||||
or
|
||||
label_replace(
|
||||
probe_success{job="blackbox-http"},
|
||||
"server", "$1", "instance", "(.+)"
|
||||
)
|
||||
```
|
||||
|
||||
### Kubernetes
|
||||
|
||||
```promql
|
||||
# Pod running ratio
|
||||
sum(kube_pod_status_phase{phase="Running"}) / sum(kube_pod_status_phase)
|
||||
|
||||
# Pods by namespace and phase
|
||||
sum by (namespace, phase) (kube_pod_status_phase)
|
||||
|
||||
# Top restarting containers
|
||||
topk(10, kube_pod_container_status_restarts_total)
|
||||
|
||||
# Ingress controller restarts
|
||||
kube_pod_container_status_restarts_total{namespace="ingress", pod=~".*nginx-ingress.*"}
|
||||
|
||||
# Node CPU %
|
||||
100 - (avg by (instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)
|
||||
|
||||
# Node memory %
|
||||
100 * (1 - ((node_memory_MemAvailable_bytes) / node_memory_MemTotal_bytes))
|
||||
|
||||
# Node disk usage %
|
||||
100 - ((node_filesystem_avail_bytes{mountpoint="/"} * 100) / node_filesystem_size_bytes{mountpoint="/"})
|
||||
```
|
||||
|
||||
### Databases and caches
|
||||
|
||||
```promql
|
||||
# MySQL up
|
||||
up{job="mysql"}
|
||||
|
||||
# MySQL connections
|
||||
mysql_global_status_threads_connected
|
||||
mysql_global_status_threads_running
|
||||
|
||||
# MySQL slow queries/sec
|
||||
irate(mysql_global_status_slow_queries[5m])
|
||||
|
||||
# Redis up
|
||||
redis_up
|
||||
|
||||
# Redis memory
|
||||
redis_memory_used_bytes
|
||||
|
||||
# Redis clients
|
||||
redis_connected_clients
|
||||
|
||||
# Redis hit ratio
|
||||
rate(redis_keyspace_hits_total[5m]) /
|
||||
clamp_min(rate(redis_keyspace_hits_total[5m]) + rate(redis_keyspace_misses_total[5m]), 1)
|
||||
```
|
||||
|
||||
### OpenTelemetry Collector
|
||||
|
||||
```promql
|
||||
# Collector uptime
|
||||
otelcol_process_uptime_total
|
||||
|
||||
# Metrics sent per second
|
||||
rate(otelcol_exporter_sent_metric_points_total[5m])
|
||||
|
||||
# Exporter queue size
|
||||
otelcol_exporter_queue_size
|
||||
|
||||
# Failed sends/sec
|
||||
rate(otelcol_exporter_send_failed_metric_points_total[5m])
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Recommended new panels
|
||||
|
||||
If you extend the health dashboard, consider adding:
|
||||
|
||||
- **SSL expiry alert panel** — min of `(probe_ssl_earliest_cert_expiry - time()) / 86400` with threshold 14 days.
|
||||
- **Top memory-consuming pods** — from K8s Prometheus: `topk(10, container_memory_usage_bytes{container!=""})`.
|
||||
- **Error log rate** — from Loki: `{job="hermes-mcp"} |= "error"` or `{namespace="fetcherpay"} |= "ERROR"`.
|
||||
- **Trace error rate** — from Tempo: search for spans with `status:error`.
|
||||
|
||||
---
|
||||
|
||||
## How to add a new website to monitor
|
||||
|
||||
1. Edit `monitoring/prometheus-config.yaml`.
|
||||
2. Add the URL under `static_configs.targets` in the `blackbox-http` job.
|
||||
3. Apply: `microk8s kubectl apply -f monitoring/prometheus-config.yaml`.
|
||||
4. Restart Prometheus to reload: `microk8s kubectl rollout restart deployment/prometheus -n fetcherpay`.
|
||||
5. Verify: `curl -u admin:admin_secure_2024 'https://dashboard.fetcherpay.com/api/datasources/proxy/uid/ffpaxh13af2f4e/api/v1/query?query=probe_success{instance="https://new-site.com"}'`.
|
||||
|
||||
---
|
||||
|
||||
## How to add a new exporter
|
||||
|
||||
1. Create or reuse a Deployment + Service manifest in `monitoring/`.
|
||||
2. Add a scrape job to `monitoring/prometheus-config.yaml`.
|
||||
3. Apply both.
|
||||
4. Restart Prometheus.
|
||||
5. Add a panel to the health dashboard.
|
||||
@@ -0,0 +1,248 @@
|
||||
# API Reference
|
||||
|
||||
All examples assume Grafana login `admin` / `admin_secure_2024`.
|
||||
|
||||
---
|
||||
|
||||
## Datasource UIDs
|
||||
|
||||
| Datasource | UID |
|
||||
|------------|-----|
|
||||
| Prometheus (FetcherPay) | `ffpaxh13af2f4e` |
|
||||
| Prometheus (K8s Observability) | `ffpaxh1q3zo5cc` |
|
||||
| Loki | `afpb0s2gdn6yoc` |
|
||||
| Tempo | `efpb0sa7zs0e8f` |
|
||||
| Alertmanager | `afpb0sgrf7hmoa` |
|
||||
|
||||
---
|
||||
|
||||
## Prometheus Query API
|
||||
|
||||
### FetcherPay Prometheus
|
||||
|
||||
```bash
|
||||
DS=ffpaxh13af2f4e
|
||||
QUERY='up{job="redis"}'
|
||||
|
||||
curl -u admin:admin_secure_2024 \
|
||||
-G "https://dashboard.fetcherpay.com/api/datasources/proxy/uid/${DS}/api/v1/query" \
|
||||
--data-urlencode "query=${QUERY}" \
|
||||
| python3 -m json.tool
|
||||
```
|
||||
|
||||
### Range query
|
||||
|
||||
```bash
|
||||
DS=ffpaxh13af2f4e
|
||||
QUERY='rate(otelcol_exporter_sent_metric_points_total[5m])'
|
||||
|
||||
curl -u admin:admin_secure_2024 \
|
||||
-G "https://dashboard.fetcherpay.com/api/datasources/proxy/uid/${DS}/api/v1/query_range" \
|
||||
--data-urlencode "query=${QUERY}" \
|
||||
--data-urlencode "start=$(date -d '1 hour ago' +%s)" \
|
||||
--data-urlencode "end=$(date +%s)" \
|
||||
--data-urlencode "step=60" \
|
||||
| python3 -m json.tool
|
||||
```
|
||||
|
||||
### K8s Prometheus
|
||||
|
||||
```bash
|
||||
DS=ffpaxh1q3zo5cc
|
||||
QUERY='sum by (namespace, phase) (kube_pod_status_phase)'
|
||||
|
||||
curl -u admin:admin_secure_2024 \
|
||||
-G "https://dashboard.fetcherpay.com/api/datasources/proxy/uid/${DS}/api/v1/query" \
|
||||
--data-urlencode "query=${QUERY}" \
|
||||
| python3 -m json.tool
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Grafana API
|
||||
|
||||
### List datasources
|
||||
|
||||
```bash
|
||||
curl -u admin:admin_secure_2024 \
|
||||
https://dashboard.fetcherpay.com/api/datasources \
|
||||
| python3 -m json.tool
|
||||
```
|
||||
|
||||
### Search dashboards
|
||||
|
||||
```bash
|
||||
curl -u admin:admin_secure_2024 \
|
||||
"https://dashboard.fetcherpay.com/api/search?query=health" \
|
||||
| python3 -m json.tool
|
||||
```
|
||||
|
||||
### Get dashboard JSON by UID
|
||||
|
||||
```bash
|
||||
UID=fetcherpay-health-overview
|
||||
|
||||
curl -u admin:admin_secure_2024 \
|
||||
"https://dashboard.fetcherpay.com/api/dashboards/uid/${UID}" \
|
||||
| python3 -m json.tool
|
||||
```
|
||||
|
||||
### Import / update a dashboard
|
||||
|
||||
Save this as `dashboard.json`, then:
|
||||
|
||||
```bash
|
||||
curl -u admin:admin_secure_2024 \
|
||||
-X POST https://dashboard.fetcherpay.com/api/dashboards/db \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d @dashboard.json
|
||||
```
|
||||
|
||||
Example `dashboard.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"dashboard": {
|
||||
"title": "My New Dashboard",
|
||||
"tags": ["squaremcp"],
|
||||
"timezone": "browser",
|
||||
"schemaVersion": 36,
|
||||
"refresh": "30s",
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Website Healthy %",
|
||||
"type": "stat",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "avg(probe_success{job=\"blackbox-http\"}) * 100",
|
||||
"refId": "A",
|
||||
"datasource": {"uid": "ffpaxh13af2f4e", "type": "prometheus"}
|
||||
}
|
||||
],
|
||||
"gridPos": {"h": 4, "w": 12, "x": 0, "y": 0}
|
||||
}
|
||||
]
|
||||
},
|
||||
"folderId": 0,
|
||||
"overwrite": true,
|
||||
"message": "Imported via API"
|
||||
}
|
||||
```
|
||||
|
||||
### Import from grafana.com
|
||||
|
||||
Find the dashboard ID (e.g. `13407` for Loki), download, then upload:
|
||||
|
||||
```bash
|
||||
DASHBOARD_ID=13407
|
||||
curl -s "https://grafana.com/api/dashboards/${DASHBOARD_ID}/revisions/latest/download" \
|
||||
| python3 -c '
|
||||
import json, sys
|
||||
d = json.load(sys.stdin)
|
||||
d.pop("id", None)
|
||||
print(json.dumps({"dashboard": d, "folderId": 0, "overwrite": True}))
|
||||
' > /tmp/import.json
|
||||
|
||||
curl -u admin:admin_secure_2024 \
|
||||
-X POST https://dashboard.fetcherpay.com/api/dashboards/db \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d @/tmp/import.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Loki API
|
||||
|
||||
### Query logs
|
||||
|
||||
```bash
|
||||
DS=afpb0s2gdn6yoc
|
||||
QUERY='{namespace="fetcherpay"} |~ "ERROR|error|Error"'
|
||||
|
||||
curl -u admin:admin_secure_2024 \
|
||||
-G "https://dashboard.fetcherpay.com/api/datasources/proxy/uid/${DS}/loki/api/v1/query_range" \
|
||||
--data-urlencode "query=${QUERY}" \
|
||||
--data-urlencode "start=$(date -d '1 hour ago' +%s)000000000" \
|
||||
--data-urlencode "end=$(date +%s)000000000" \
|
||||
--data-urlencode "limit=100" \
|
||||
| python3 -m json.tool
|
||||
```
|
||||
|
||||
### Label values
|
||||
|
||||
```bash
|
||||
curl -u admin:admin_secure_2024 \
|
||||
"https://dashboard.fetcherpay.com/api/datasources/proxy/uid/afpb0s2gdn6yoc/loki/api/v1/label/namespace/values" \
|
||||
| python3 -m json.tool
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Tempo API
|
||||
|
||||
### Search recent traces
|
||||
|
||||
```bash
|
||||
curl -u admin:admin_secure_2024 \
|
||||
-G "https://dashboard.fetcherpay.com/api/datasources/proxy/uid/efpb0sa7zs0e8f/api/search" \
|
||||
--data-urlencode "limit=20" \
|
||||
| python3 -m json.tool
|
||||
```
|
||||
|
||||
### Query by Trace ID
|
||||
|
||||
```bash
|
||||
TRACE_ID=<trace-id>
|
||||
curl -u admin:admin_secure_2024 \
|
||||
"https://dashboard.fetcherpay.com/api/datasources/proxy/uid/efpb0sa7zs0e8f/api/traces/${TRACE_ID}" \
|
||||
| python3 -m json.tool
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Alertmanager API
|
||||
|
||||
### Active alerts
|
||||
|
||||
```bash
|
||||
curl -u admin:admin_secure_2024 \
|
||||
"https://dashboard.fetcherpay.com/api/datasources/proxy/uid/afpb0sgrf7hmoa/api/v2/alerts" \
|
||||
| python3 -m json.tool
|
||||
```
|
||||
|
||||
### Silences
|
||||
|
||||
```bash
|
||||
curl -u admin:admin_secure_2024 \
|
||||
"https://dashboard.fetcherpay.com/api/datasources/proxy/uid/afpb0sgrf7hmoa/api/v2/silences" \
|
||||
| python3 -m json.tool
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Kubernetes API via `kubectl proxy`
|
||||
|
||||
Because the kubelet TLS cert does not include `104.190.60.129`, `kubectl exec`/`port-forward`/`logs` can fail. `kubectl proxy` works because it talks to the API server.
|
||||
|
||||
```bash
|
||||
microk8s kubectl proxy --port=8000 &
|
||||
|
||||
# Access a service HTTP endpoint through the proxy
|
||||
curl http://localhost:8000/api/v1/namespaces/observability/services/otel-collector:metrics/proxy/metrics
|
||||
|
||||
# Stop proxy when done
|
||||
kill %1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Hermes Communications API (cross-reference)
|
||||
|
||||
The monitoring stack watches `https://hermes.squaremcp.com/health`. For the Hermes business API, see `SquareMCP/deployments/2026-06-15-phase1-communications-deploy-handoff.md`.
|
||||
|
||||
Quick health check:
|
||||
|
||||
```bash
|
||||
curl -s https://hermes.squaremcp.com/health
|
||||
```
|
||||
@@ -0,0 +1,162 @@
|
||||
# Alerts and Incident Response
|
||||
|
||||
**Alertmanager:** configured in `monitoring/alertmanager-config.yaml`
|
||||
**Receivers:**
|
||||
- Email → `garfield@squaremcp.com` via Azure Comm Services (`smtp.azurecomm.net:587`)
|
||||
- Slack → `#alerts` via existing webhook
|
||||
|
||||
---
|
||||
|
||||
## Current alert routing
|
||||
|
||||
| Alert | Severity | Route | Action |
|
||||
|-------|----------|-------|--------|
|
||||
| Default alerts | critical/warning | Slack `#alerts` + email | Page/notify |
|
||||
| `InfoInhibitor` | info | `null` | Suppressed |
|
||||
| `Watchdog` | none | `null` | Heartbeat, no notification |
|
||||
|
||||
---
|
||||
|
||||
## Alerts to pay attention to
|
||||
|
||||
### Website down
|
||||
|
||||
**Likely cause:** certificate expiry, DNS issue, ingress misconfig, service crash, host/network outage.
|
||||
|
||||
**PromQL:** `probe_success{job="blackbox-http"} == 0`
|
||||
|
||||
**Response:**
|
||||
1. Check `probe_duration_seconds` to see if it is a timeout vs. connection refused.
|
||||
2. Test manually: `curl -I https://<site>`.
|
||||
3. Check ingress: `microk8s kubectl get ingress -A` and `microk8s kubectl get pods -n ingress`.
|
||||
4. Check the backing pod logs: `microk8s kubectl logs -n <namespace> -l app=<app> --insecure-skip-tls-verify-backend=true`.
|
||||
5. Check SSL expiry: `(probe_ssl_earliest_cert_expiry - time()) / 86400`.
|
||||
|
||||
### MySQL down
|
||||
|
||||
**PromQL:** `up{job="mysql"} == 0` or `mysql_up == 0`
|
||||
|
||||
**Response:**
|
||||
1. MySQL runs as a Docker container on the host at `:3306`.
|
||||
2. Check container: `docker ps | grep mysql` or `ss -tlnp | grep 3306`.
|
||||
3. If stopped, restart from the `fetcherpay_mysql_data` volume (see previous deployment notes).
|
||||
4. Check mysql-exporter pod: `microk8s kubectl get pods -n fetcherpay -l app=mysql-exporter`.
|
||||
|
||||
### Redis down
|
||||
|
||||
**PromQL:** `up{job="redis"} == 0` or `redis_up == 0`
|
||||
|
||||
**Response:**
|
||||
1. Check Redis pod: `microk8s kubectl get pods -n fetcherpay -l app=redis`.
|
||||
2. Check logs: `microk8s kubectl logs -n fetcherpay -l app=redis --insecure-skip-tls-verify-backend=true`.
|
||||
3. Verify exporter: `microk8s kubectl get pods -n fetcherpay -l app=redis-exporter`.
|
||||
|
||||
### Prometheus down
|
||||
|
||||
**PromQL:** `up{job="prometheus"} == 0`
|
||||
|
||||
**Response:**
|
||||
1. Check pod: `microk8s kubectl get pods -n fetcherpay -l app=prometheus`.
|
||||
2. Check logs; common issue is invalid config.
|
||||
3. If ConfigMap changed, restart: `microk8s kubectl rollout restart deployment/prometheus -n fetcherpay`.
|
||||
|
||||
### OTel collector down
|
||||
|
||||
**PromQL:** `up{job="otel-collector"} == 0` or absent `otelcol_process_uptime_total`
|
||||
|
||||
**Response:**
|
||||
1. Check pod: `microk8s kubectl get pods -n observability -l app=otel-collector`.
|
||||
2. Common failure: invalid YAML config. Fix and reapply `monitoring/opentelemetry-collector.yaml`.
|
||||
3. Restart: `microk8s kubectl rollout restart deployment/otel-collector -n observability`.
|
||||
|
||||
### High container restart rate
|
||||
|
||||
**PromQL:** `rate(kube_pod_container_status_restarts_total[5m]) > 0.01`
|
||||
|
||||
**Response:**
|
||||
1. Identify pod/namespace from labels.
|
||||
2. Check events: `microk8s kubectl describe pod -n <ns> <pod>`.
|
||||
3. Check logs (with TLS skip flag if needed).
|
||||
4. Investigate resource limits, OOM, liveness probe failures.
|
||||
|
||||
### Node CPU / memory / disk high
|
||||
|
||||
**PromQL:**
|
||||
- CPU: `100 - (avg by (instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 85`
|
||||
- Memory: `100 * (1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)) > 85`
|
||||
- Disk: `100 - ((node_filesystem_avail_bytes{mountpoint="/"} * 100) / node_filesystem_size_bytes{mountpoint="/"}) > 85`
|
||||
|
||||
**Response:**
|
||||
1. Identify which pod/container is consuming resources via K8s Prometheus.
|
||||
2. Scale, restart, or optimize the offending workload.
|
||||
3. For disk: clean logs, old images (`docker system prune -a`), or expand storage.
|
||||
|
||||
### SSL certificate expiring
|
||||
|
||||
**PromQL:** `(probe_ssl_earliest_cert_expiry{job="blackbox-http"} - time()) / 86400 < 14`
|
||||
|
||||
**Response:**
|
||||
1. Renew the cert (likely cert-manager handles this).
|
||||
2. Check cert-manager: `microk8s kubectl get certificates -A`.
|
||||
3. Force renewal if stuck.
|
||||
|
||||
---
|
||||
|
||||
## Pre-existing issues that will trigger alerts
|
||||
|
||||
These are already unhealthy and will show red in dashboards. They are not caused by recent deployments.
|
||||
|
||||
### `fetcherpay-leads-api` / `fetcherpay-leads-worker` ImagePullBackOff
|
||||
|
||||
**Why:** stale image references to dead registry `23.120.207.35:32000`. Current registry is `localhost:32000`, and tag `v16-import-fix` does not exist.
|
||||
|
||||
**Fix options:**
|
||||
1. Update Deployments to use `localhost:32000/fetcherpay/leads-api:latest`.
|
||||
2. Delete the Deployments if the leads feature is abandoned.
|
||||
|
||||
### `nginx-ingress-microk8s-controller` restarts
|
||||
|
||||
**Why:** chronic single-node instability (~1 restart/day over 9 months). Likely OOM, liveness timeouts, or containerd sandbox churn.
|
||||
|
||||
**Mitigation:**
|
||||
- Add memory request/limit to the ingress DaemonSet.
|
||||
- Monitor `kube_pod_container_status_restarts_total{namespace="ingress"}`.
|
||||
- Check `dmesg` / kernel OOM logs if restarts spike.
|
||||
|
||||
---
|
||||
|
||||
## How to add a new alert rule
|
||||
|
||||
1. Edit the Prometheus ConfigMap or kube-prometheus-stack PrometheusRule CRDs.
|
||||
2. For FetcherPay Prometheus, add a `rule_files` section or use `recording_rules`/`alerting_rules` in `monitoring/prometheus-config.yaml`.
|
||||
3. Apply and restart Prometheus.
|
||||
4. Verify in Alertmanager: `https://dashboard.fetcherpay.com/alerting/` or API.
|
||||
|
||||
Example simple rule:
|
||||
|
||||
```yaml
|
||||
groups:
|
||||
- name: fetcherpay
|
||||
rules:
|
||||
- alert: WebsiteDown
|
||||
expr: probe_success{job="blackbox-http"} == 0
|
||||
for: 2m
|
||||
labels:
|
||||
severity: critical
|
||||
annotations:
|
||||
summary: "Website {{ $labels.instance }} is down"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Runbook quick-decision tree
|
||||
|
||||
```
|
||||
ALERT fires
|
||||
│
|
||||
├─ Is it a website? → check probe_success, curl manually, check ingress
|
||||
├─ Is it MySQL/Redis/Prometheus/OTel? → check pod status, restart if needed
|
||||
├─ Is it a pod restart spike? → describe pod, check OOM/probes
|
||||
├─ Is it node resource pressure? → identify top consumer, scale/restart
|
||||
└─ Is it a known pre-existing issue? → document, do not page unless it worsens
|
||||
```
|
||||
@@ -0,0 +1,127 @@
|
||||
# AI Agent Guide — Observability Stack
|
||||
|
||||
This guide is written for coding/operations AI agents working on FetcherPay / SquareMCP.
|
||||
|
||||
---
|
||||
|
||||
## Your job
|
||||
|
||||
Use the observability stack to:
|
||||
1. Verify system health before and after changes.
|
||||
2. Diagnose failures quickly.
|
||||
3. Avoid false alarms by understanding pre-existing issues.
|
||||
4. Document what you find back into this vault.
|
||||
|
||||
---
|
||||
|
||||
## Checklist before making changes
|
||||
|
||||
- [ ] Open the health dashboard: https://dashboard.fetcherpay.com/d/fetcherpay-health-overview
|
||||
- [ ] Confirm no unexpected red panels (ignore known issues in `07-known-issues.md`).
|
||||
- [ ] If touching Hermes, hit `https://hermes.squaremcp.com/health`.
|
||||
- [ ] If touching MySQL, confirm `redis_up` and MySQL `up` are 1.
|
||||
- [ ] If touching ingress, confirm `nginx-ingress-microk8s-controller` is Running.
|
||||
|
||||
---
|
||||
|
||||
## How to query state programmatically
|
||||
|
||||
Use the APIs in `03-api-reference.md`. Preferred pattern:
|
||||
|
||||
```python
|
||||
import json, urllib.request, urllib.error, base64
|
||||
|
||||
GRAFANA_URL = 'https://dashboard.fetcherpay.com'
|
||||
AUTH = base64.b64encode(b'admin:admin_secure_2024').decode()
|
||||
|
||||
def prom_query(uid, q):
|
||||
url = f'{GRAFANA_URL}/api/datasources/proxy/uid/{uid}/api/v1/query?query={urllib.parse.quote(q)}'
|
||||
req = urllib.request.Request(url)
|
||||
req.add_header('Authorization', f'Basic {AUTH}')
|
||||
with urllib.request.urlopen(req, timeout=30) as r:
|
||||
return json.loads(r.read())
|
||||
|
||||
# Example: are all websites healthy?
|
||||
res = prom_query('ffpaxh13af2f4e', 'avg(probe_success{job="blackbox-http"})')
|
||||
healthy_pct = float(res['data']['result'][0]['value'][1]) * 100
|
||||
print(f'{healthy_pct:.0f}% websites healthy')
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Common agent tasks
|
||||
|
||||
### Check if a pod is running
|
||||
|
||||
```bash
|
||||
microk8s kubectl get pods -n <namespace> -l app=<app>
|
||||
```
|
||||
|
||||
If direct `logs`/`exec` fails with TLS error, use:
|
||||
|
||||
```bash
|
||||
microk8s kubectl logs -n <namespace> -l app=<app> --insecure-skip-tls-verify-backend=true --tail=50
|
||||
```
|
||||
|
||||
Or use `kubectl proxy` for HTTP health endpoints:
|
||||
|
||||
```bash
|
||||
microk8s kubectl proxy --port=8000 &
|
||||
curl http://localhost:8000/api/v1/namespaces/<ns>/services/<svc>:<port>/proxy/<path>
|
||||
```
|
||||
|
||||
### Add a new website to the health dashboard
|
||||
|
||||
1. Edit `hermes-mcp/monitoring/prometheus-config.yaml`.
|
||||
2. Add URL to `blackbox-http` targets.
|
||||
3. Commit, push, apply.
|
||||
4. Restart Prometheus.
|
||||
5. Verify with `probe_success{instance="https://new-site.com"}`.
|
||||
|
||||
### Add a new metric panel to a dashboard
|
||||
|
||||
1. Get the dashboard JSON via `/api/dashboards/uid/<uid>`.
|
||||
2. Add a panel object with a PromQL target.
|
||||
3. POST back to `/api/dashboards/db` with `overwrite: true`.
|
||||
4. Test the query first via the Prometheus query API.
|
||||
|
||||
### Investigate an alert
|
||||
|
||||
1. Read the alert labels (severity, instance, job).
|
||||
2. Look up the matching PromQL in `04-alerts-and-response.md`.
|
||||
3. Query the metric directly.
|
||||
4. Check pod status and logs.
|
||||
5. Fix or silence, then document the outcome in this vault.
|
||||
|
||||
---
|
||||
|
||||
## What NOT to do
|
||||
|
||||
- **Do not** restart the ingress controller unless it is actually failing requests.
|
||||
- **Do not** delete the `fetcherpay-leads-*` pods expecting them to fix themselves — they have stale image refs.
|
||||
- **Do not** run `docker system prune` without checking if MySQL or MT5 containers are running.
|
||||
- **Do not** leave `kubectl proxy` background processes running indefinitely.
|
||||
- **Do not** change `monitoring/alertmanager-config.yaml` without testing SMTP/Slack delivery.
|
||||
|
||||
---
|
||||
|
||||
## Decision tree
|
||||
|
||||
```
|
||||
User asks "Is X down?"
|
||||
│
|
||||
├─ Check health dashboard first
|
||||
├─ If red, query probe_success / up metric
|
||||
├─ If pod-related, check kubectl get pods / logs
|
||||
├─ If known issue (leads, nginx restarts), explain root cause
|
||||
└─ Update this vault if the failure is new or unresolved
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Vault update discipline
|
||||
|
||||
After every significant investigation or change:
|
||||
1. Update the relevant runbook file.
|
||||
2. If it is a deployment, also add/update `SquareMCP/deployments/YYYY-MM-DD-*.md`.
|
||||
3. Cross-link from `00-index.md` if a new topic is introduced.
|
||||
@@ -0,0 +1,98 @@
|
||||
# Human Guide — Observability Stack
|
||||
|
||||
For humans monitoring FetcherPay / SquareMCP.
|
||||
|
||||
---
|
||||
|
||||
## Daily workflow
|
||||
|
||||
1. Open the main dashboard: https://dashboard.fetcherpay.com/d/fetcherpay-health-overview
|
||||
2. Scan for red panels.
|
||||
3. Ignore the known pre-existing issues:
|
||||
- `fetcherpay-leads-api` / `fetcherpay-leads-worker` ImagePullBackOff
|
||||
- `nginx-ingress-microk8s-controller` restart count slowly climbing
|
||||
4. Anything else red → investigate using this runbook.
|
||||
|
||||
---
|
||||
|
||||
## Grafana basics
|
||||
|
||||
- **Login:** `admin` / `admin_secure_2024`
|
||||
- **Time picker:** top-right. Default is "Last 1 hour". Use "Last 6 hours" or "Last 24 hours" for trends.
|
||||
- **Refresh:** next to the time picker. Set to 30s for live views, Off when investigating history.
|
||||
- **Variables:** some dashboards have dropdowns at the top (namespace, pod, job).
|
||||
- **Panel menu:** click the panel title → **Edit** to see the query, **Inspect → Data** to see raw values.
|
||||
|
||||
---
|
||||
|
||||
## Reading the health overview dashboard
|
||||
|
||||
| Section | What to watch |
|
||||
|---------|---------------|
|
||||
| **Websites** | "Websites Healthy %" should be 100. Red rows in "Website Status" mean a site is down or returning non-2xx. |
|
||||
| **Kubernetes Cluster** | "Pods Running Ratio" should be close to 1. "Ingress Controller Restarts" slowly climbing is known; a sudden spike is bad. |
|
||||
| **Databases & Caches** | MySQL and Redis panels should be green/healthy. Memory graphs show normal usage over time. |
|
||||
| **Infrastructure & Observability** | Prometheus, OTel collector, Blackbox exporter should be up. "OTel Metrics Sent / sec" should be > 0. |
|
||||
|
||||
---
|
||||
|
||||
## Investigating a problem
|
||||
|
||||
### A website is red
|
||||
|
||||
1. Hover over the "Website Status" row to see which URL is failing.
|
||||
2. Open a terminal and test it: `curl -I https://<site>`.
|
||||
3. Check the "Website Response Time" panel — timeout vs fast failure tells you if it is DNS/network vs app crash.
|
||||
4. If the site is a K8s service, check the backing pod: `microk8s kubectl get pods -n <namespace>`.
|
||||
|
||||
### MySQL or Redis is red
|
||||
|
||||
1. Check the service pod is Running.
|
||||
2. Look at the error log panel if available.
|
||||
3. For MySQL, it runs in Docker on the host — check `docker ps | grep -i mysql`.
|
||||
|
||||
### A pod keeps restarting
|
||||
|
||||
1. Note the namespace/pod from the "Top Container Restarts" panel.
|
||||
2. Run: `microk8s kubectl describe pod -n <ns> <pod>`.
|
||||
3. Look at the **Events** and **Last State** sections for OOMKilled, Error, or CrashLoopBackOff.
|
||||
4. If logs are needed, use the TLS skip flag: `microk8s kubectl logs -n <ns> <pod> --previous --insecure-skip-tls-verify-backend=true`.
|
||||
|
||||
### You get an email/Slack alert
|
||||
|
||||
1. Read the alert summary.
|
||||
2. Open Grafana and find the matching metric.
|
||||
3. Follow the response steps in `04-alerts-and-response.md`.
|
||||
4. If it is a known issue, acknowledge and move on.
|
||||
5. If it is new, fix it and document it.
|
||||
|
||||
---
|
||||
|
||||
## Adding a human-readable note to a dashboard
|
||||
|
||||
1. Open the dashboard → **Settings** (gear icon) → **General**.
|
||||
2. Add a description or tags.
|
||||
3. Save with a meaningful message.
|
||||
|
||||
---
|
||||
|
||||
## Keyboard shortcuts
|
||||
|
||||
- `d + s` — dashboard settings
|
||||
- `e` — edit panel (when focused)
|
||||
- `v` — toggle view mode
|
||||
- `t` — change time range
|
||||
- `r` — refresh
|
||||
|
||||
---
|
||||
|
||||
## Who to notify
|
||||
|
||||
| Issue | Notify |
|
||||
|-------|--------|
|
||||
| Site-wide outage | `#alerts` Slack + garfield@squaremcp.com |
|
||||
| Hermes API down | Engineering + product |
|
||||
| MySQL/Redis down | Engineering immediately |
|
||||
| SSL cert < 7 days | Engineering |
|
||||
| Slow website response | Engineering + infrastructure |
|
||||
| Known issues unchanged | No action needed unless worsening |
|
||||
@@ -0,0 +1,113 @@
|
||||
# Known Issues
|
||||
|
||||
Last updated: 2026-06-16
|
||||
|
||||
These issues are pre-existing and not caused by recent deployments. They will show as unhealthy in dashboards/alerts.
|
||||
|
||||
---
|
||||
|
||||
## `fetcherpay-leads-api` — `ImagePullBackOff`
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| **Pod** | `fetcherpay-leads-api-789995b658-c2dp2` |
|
||||
| **Image** | `23.120.207.35:32000/fetcherpay/leads-api:latest` |
|
||||
| **Status** | `ImagePullBackOff` |
|
||||
| **Restarts** | 173 |
|
||||
|
||||
**Root cause:** the image registry IP `23.120.207.35:32000` no longer responds. The current registry is `localhost:32000`, and `fetcherpay/leads-api:latest` exists there.
|
||||
|
||||
**Fix:** update the Deployment image to `localhost:32000/fetcherpay/leads-api:latest`.
|
||||
|
||||
**Impact:** leads API is unavailable.
|
||||
|
||||
---
|
||||
|
||||
## `fetcherpay-leads-worker` — `ImagePullBackOff`
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| **Pod** | `fetcherpay-leads-worker-85b96f8b56-kshdf` |
|
||||
| **Image** | `23.120.207.35:32000/fetcherpay/leads-api:v16-import-fix` |
|
||||
| **Status** | `ImagePullBackOff` |
|
||||
| **Restarts** | 0 (new pod) |
|
||||
|
||||
**Root cause:** same dead registry IP, and tag `v16-import-fix` does not exist in `localhost:32000`. Available tags: `latest`, `v15-clean-imports`, `v14-import-fix`, `v13-ssl-fix`, `v11-smtp-fix`.
|
||||
|
||||
**Fix:** repoint to a valid tag such as `localhost:32000/fetcherpay/leads-api:v15-clean-imports` or `latest`.
|
||||
|
||||
**Impact:** leads background worker is unavailable.
|
||||
|
||||
---
|
||||
|
||||
## `nginx-ingress-microk8s-controller` — chronic restarts
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| **Pod** | `nginx-ingress-microk8s-controller-w8ddl` |
|
||||
| **Namespace** | `ingress` |
|
||||
| **Restarts** | 314+ over ~269 days (~1.17/day) |
|
||||
| **Current state** | Running, Ready |
|
||||
|
||||
**Root cause:** chronic single-node instability. Most likely memory pressure / OOMKilled, liveness probe timeouts, or containerd/CRI-o sandbox churn. No recent events because the pod is currently healthy.
|
||||
|
||||
**Mitigation:**
|
||||
- Add memory request/limit to the ingress DaemonSet.
|
||||
- Monitor restart rate; sudden spikes warrant investigation.
|
||||
- Check kernel OOM logs (`dmesg | grep -i kill`) after the next restart.
|
||||
|
||||
**Impact:** brief edge-routing blips during restarts; ingress recovers automatically.
|
||||
|
||||
---
|
||||
|
||||
## `cm-acme-http-solver-k5m82` — high restart count
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| **Namespace** | `fetcherpay` |
|
||||
| **Restarts** | 189 |
|
||||
| **Current state** | Running |
|
||||
|
||||
**Root cause:** cert-manager ACME challenge solver pod. Frequent restarts may indicate certificate renewal churn or challenge failures.
|
||||
|
||||
**Action:** check cert-manager logs if SSL expiry alerts appear.
|
||||
|
||||
---
|
||||
|
||||
## Kubelet TLS cert mismatch
|
||||
|
||||
**Symptom:** `kubectl exec`, `port-forward`, `logs`, `attach` fail with:
|
||||
|
||||
```
|
||||
tls: failed to verify certificate: x509: certificate is valid for 23.120.207.35, 172.17.0.1, ... not 104.190.60.129
|
||||
```
|
||||
|
||||
**Root cause:** the kubelet serving certificate does not include the public IP `104.190.60.129`.
|
||||
|
||||
**Workarounds:**
|
||||
- For logs: `kubectl logs ... --insecure-skip-tls-verify-backend=true`
|
||||
- For HTTP checks: `kubectl proxy --port=8000` and use the API server proxy URL.
|
||||
- For shell access: use `kubectl debug` node or SSH directly to `art0`.
|
||||
|
||||
---
|
||||
|
||||
## MT5 Docker port bindings
|
||||
|
||||
**Started:** 2026-06-16
|
||||
**Container:** `mt5` (`gmag11/metatrader5_vnc:1.1`)
|
||||
**Host ports bound:** `0.0.0.0:3000`, `0.0.0.0:8001`
|
||||
|
||||
**Notes:**
|
||||
- K8s services internally use ports 3000 and 8001 as ClusterIP, but those are not bound on the host.
|
||||
- NodePorts use the 30000–32767 range.
|
||||
- MT5 does **not** currently conflict with K8s.
|
||||
- If you later need to `kubectl port-forward` to `localhost:3000` or `:8001`, stop MT5 first.
|
||||
|
||||
---
|
||||
|
||||
## Recommended cleanup actions
|
||||
|
||||
1. **Decide on leads service fate.** Either fix image refs or delete the Deployments.
|
||||
2. **Stabilize ingress controller.** Add memory limits and monitor restart rate.
|
||||
3. **Regenerate kubelet cert** to include `104.190.60.129` if direct pod exec becomes critical.
|
||||
4. **Add alert rules** for the issues above so severity is known and routed correctly.
|
||||
Reference in new issue
Block a user