3.9 KiB
3.9 KiB
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:
- Verify system health before and after changes.
- Diagnose failures quickly.
- Avoid false alarms by understanding pre-existing issues.
- 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_upand MySQLupare 1. - If touching ingress, confirm
nginx-ingress-microk8s-controlleris Running.
How to query state programmatically
Use the APIs in 03-api-reference.md. Preferred pattern:
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
microk8s kubectl get pods -n <namespace> -l app=<app>
If direct logs/exec fails with TLS error, use:
microk8s kubectl logs -n <namespace> -l app=<app> --insecure-skip-tls-verify-backend=true --tail=50
Or use kubectl proxy for HTTP health endpoints:
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
- Edit
hermes-mcp/monitoring/prometheus-config.yaml. - Add URL to
blackbox-httptargets. - Commit, push, apply.
- Restart Prometheus.
- Verify with
probe_success{instance="https://new-site.com"}.
Add a new metric panel to a dashboard
- Get the dashboard JSON via
/api/dashboards/uid/<uid>. - Add a panel object with a PromQL target.
- POST back to
/api/dashboards/dbwithoverwrite: true. - Test the query first via the Prometheus query API.
Investigate an alert
- Read the alert labels (severity, instance, job).
- Look up the matching PromQL in
04-alerts-and-response.md. - Query the metric directly.
- Check pod status and logs.
- 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 prunewithout checking if MySQL or MT5 containers are running. - Do not leave
kubectl proxybackground processes running indefinitely. - Do not change
monitoring/alertmanager-config.yamlwithout 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:
- Update the relevant runbook file.
- If it is a deployment, also add/update
SquareMCP/deployments/YYYY-MM-DD-*.md. - Cross-link from
00-index.mdif a new topic is introduced.