Grafana dashboards (platform ops)
Internal Grafana on the ops VPS (Infinity datasource) reads platform Pages APIs behind Cloudflare Access. JSON lives in social/grafana/; regenerate with the build scripts, then import or rely on file provisioning.
Related: social/grafana/README.md · platform admin · platform apply checklist · platform billing · account plans Stripe
Dashboards
| Dashboard | UID | API | Import JSON |
|---|---|---|---|
| Lovely Home — Social Insights | lovely-home-social-insights | GET /api/platform/social-insights | lovely-home-social-insights-dashboard.json |
| Lovely Home — Stripe Billing | lovely-home-stripe-billing | same URL → billing block | lovely-home-stripe-billing-dashboard.json |
| Lovely Home — AI usage | lovely-home-ai-usage | GET /api/platform/ai-usage | lovely-home-ai-usage-dashboard.json |
| Lovely Home — Cloudflare Billing | lovely-home-cloudflare-billing | GET /api/platform/cloudflare-billing | lovely-home-cloudflare-billing-dashboard.json |
| Lovely Home — E2E lifecycle | lovely-home-e2e-lifecycle | GET /api/platform/e2e-lifecycle-runs | lovely-home-e2e-lifecycle-dashboard.json |
| Lovely Home — Signup funnel | lovely-home-signup-funnel | GET /api/platform/signup-funnel | lovely-home-signup-funnel-dashboard.json |
| Lovely Home — Website visitors | lovely-home-website-visitors | GET /api/platform/social-insights?view=website-visitors | lovely-home-website-visitors-dashboard.json |
| Lovely Home — CI runner queue | lovely-home-ci-runner-queue | GET /api/platform/ci-runner-queue | lovely-home-ci-runner-queue-dashboard.json |
| Lovely Home — GitHub Actions usage | lovely-home-github-actions-usage | GET /api/platform/github-actions-usage | lovely-home-github-actions-usage-dashboard.json |
Same Infinity datasource for all nine: base URL is the platform hostname; custom headers:
X-Lovely-Client-Id(value: the service token client ID)X-Lovely-Client-Secret(value: the service token client secret)
Not CF-Access-Client-Id / CF-Access-Client-Secret: Cloudflare removes those two before the request reaches the platform, so the API answers 401 to the right token (#1562).
Values come from Terraform outputs social_insights_service_token_client_id / social_insights_service_token_client_secret (also set as SOCIAL_INSIGHTS_CF_ACCESS_* on platform Pages).
Access + Pages middleware (required for Grafana)
Grafana uses service-token headers, not operator OTP. Two layers must allow the path:
- Zero Trust Access bypass apps (Terraform
platform_admin):platform.lovely-home.co.uk/api/platform/social-insightsplatform.lovely-home.co.uk/api/platform/ai-usageplatform.lovely-home.co.uk/api/platform/cloudflare-billingplatform.lovely-home.co.uk/api/platform/e2e-lifecycle-runsplatform.lovely-home.co.uk/api/platform/signup-funnelplatform.lovely-home.co.uk/api/platform/ci-runner-queueplatform.lovely-home.co.uk/api/platform/github-actions-usage
- Pages Access middleware skip in
functions/lib/platformAccessBypass.jsfor the same paths (and Stripe webhook / public signup as documented elsewhere).
Then the Function validates the service-token headers (app 401 if missing/wrong).
Symptoms
| Symptom | Likely cause |
|---|---|
Every panel No data; curl to the API returns Access 302 login | Missing Zero Trust bypass or missing Pages middleware bypass |
App 401 UNAUTHORIZED without headers, 200 with Infinity headers | Auth OK — check date range, secrets, or provider ok / message in JSON |
Workers AI empty, OpenAI NOT_CONFIGURED | Set PLATFORM_OPENAI_ADMIN_KEY (see below); Workers AI needs Account Analytics Read on PLATFORM_CF_API_TOKEN |
| Panels were fine, then empty after Terraform | Pages env replaced — run Platform apply checklist before the next apply |
Every panel 504 context deadline exceeded (Client.Timeout exceeded while awaiting headers), but curl from the VPS gets a fast 401 | Grafana's container has lost outbound networking. It runs under snap Docker, and the regular Docker (invoice app) rewrites iptables when it recreates containers. Run sudo snap restart docker, and move Grafana to the regular Docker (below) so it doesn't recur. To confirm first: sudo nsenter -t $(pgrep -f 'grafana server' | head -1) -n curl -sS -o /dev/null -w '%{http_code}\n' --max-time 15 --resolve platform.lovely-home.co.uk:443:{IP} https://platform.lovely-home.co.uk/api/platform/signup-funnel. A timeout means traffic is blocked; 401 means it's fine. (#1000; permanent fix #1001) |
After changing Access apps: terraform apply for platform_admin. After changing platformAccessBypass.js: merge to main and wait for home-dashboard-platform production deploy (no Terraform).
Access service token (Grafana Infinity headers)
Terraform creates one Grafana social insights Access service token (duration = 8760h, ~1 year). The same client ID and secret, sent as X-Lovely-Client-Id / X-Lovely-Client-Secret, work for all seven Infinity-backed APIs above (including E2E lifecycle POST from CI).
You only need to refresh Infinity when:
- Terraform creates or replaces that token (first-time apply, import recovery, or manual destroy in Zero Trust) — sync from
terraform outputand update Infinity; Pages env vars update on the next successful platform_admin apply + deploy. - The token expires (~annually) — rare if Terraform keeps managing it.
Routine platform deploys and dashboard JSON changes do not rotate the token.
Social Insights
Meta Instagram/Facebook metrics from D1 (SOCIAL_INSIGHTS_DB) plus Cloudflare website zone traffic (website block).
- Collect workflow: social/META_INSIGHTS.md (
.github/workflows/social-insights.yml, every 3 hours). After API or dashboard JSON changes, redeploy platform admin (Pages) andgit pullon the Grafana VPS (or re-import JSON). Re-run Social — collect Meta insights once so D1 picks up corrected Instagramviews. - Website GraphQL needs
PLATFORM_CF_ZONE_ID+PLATFORM_CF_API_TOKEN - Workers AI and Claude are not on this dashboard anymore — use AI usage (Claude moved from
claudeUsagehere toclaudeon ai-usage)
Regenerate:
GRAFANA_INFINITY_UID=cfzakgwkklxc0a node social/grafana/build-dashboard.mjsStripe Billing
Uses billing on social-insights (live Stripe, non-PII). See platform-billing.md.
GRAFANA_INFINITY_UID=cfzakgwkklxc0a node social/grafana/build-billing-dashboard.mjsAI usage (Workers AI + OpenAI + Claude D1)
Endpoint: https://platform.lovely-home.co.uk/api/platform/ai-usage?from=YYYY-MM-DD&to=YYYY-MM-DD
With no dates it covers the last 7 days. ?period=month gives month-to-date instead (1st of the UTC month to today), which the cost alerts use (#1028).
| Provider | Data | Config |
|---|---|---|
| Workers AI | Neurons (est.), tokens, requests, billable USD after 10k free neurons/day @ $0.011/1k neurons; daily + running total | PLATFORM_CF_API_TOKEN with Account → Analytics → Read (and account id). GraphQL retention ~31 days — longer Grafana ranges are clamped server-side. Query uses datetime_gt / datetime_lt on aiInferenceAdaptiveGroups; when to is the current UTC day the upper bound is capped to now (endCappedToNow) so Cloudflare does not see a future end time. Same-day buckets may lag ~1h. Dashboard panel Workers AI API status shows ok, message, rangeClamped. |
| OpenAI | Completions usage + organization costs (daily + running total) | PLATFORM_OPENAI_ADMIN_KEY — OpenAI Organization Admin key (Admin keys), not a project sk- key. Terraform: platform_openai_admin_key → Pages secret. |
| Claude | Social automation usage from D1 (claude_usage), same data as former Social Insights claudeUsage | SOCIAL_INSIGHTS_DB on platform Pages. Costs are estimates from social/claude-pricing.mjs, not Anthropic invoices. Rolling today/7d/30d windows and the calendar month to date (this_month, used by the cost alert and the Est. cost this month tile, #1442) use UTC. |
Auth (three layers): Grafana Infinity X-Lovely-Client-Id/Secret (Terraform social_insights_service_token_* → Pages SOCIAL_INSIGHTS_CF_ACCESS_*) must match or the API returns 401 before any provider logic runs. That is not the same as PLATFORM_CF_API_TOKEN or PLATFORM_OPENAI_ADMIN_KEY. Check Pages slots: bash scripts/verify-platform-ai-usage-pages-env.sh. Probe the live endpoint: bash scripts/verify-grafana-platform-api.sh (pass GRAFANA_CF_ACCESS_CLIENT_ID / GRAFANA_CF_ACCESS_CLIENT_SECRET or use terraform outputs).
Regenerate:
GRAFANA_INFINITY_UID=cfzakgwkklxc0a node social/grafana/build-ai-usage-dashboard.mjsCloudflare Billing (account billable usage)
Endpoint: GET /api/platform/cloudflare-billing?from=&to=
| Block | Source |
|---|---|
| Billable products | Cloudflare Billable Usage API (invoice line items for the date range) |
| Workers requests | GraphQL workersInvocationsAdaptive (by script). When to is the current UTC day, datetime_leq is capped to now (endCappedToNow) instead of end-of-day. |
| Workers AI | Same neurons / billable USD estimate as AI usage (fetchWorkersAiUsageForInsights / workersAiGraphqlTimeBounds). |
| Storage & inventory | R2 + hub D1 bytes, D1/R2/Workers/Pages counts |
Grafana panels Billable Usage API, Workers invocations, and Workers AI (top row) mirror the AI usage Workers AI API status table: check ok, message, and endCappedToNow when KPIs are zero.
Billable Usage API lag: invoice line items often trail live analytics by about one day; same-day product costs may stay at zero until Cloudflare publishes daily billable rows.
Requires PLATFORM_CF_API_TOKEN with Account → Billing → Read and Account → Analytics → Read on platform Pages.
Regenerate:
GRAFANA_INFINITY_UID=cfzakgwkklxc0a node social/grafana/build-cloudflare-billing-dashboard.mjsE2E lifecycle
Hub lifecycle E2E history from D1 (e2e_lifecycle_runs on SOCIAL_INSIGHTS_DB). CI POSTs after each run; see e2e-reporting.md.
Regenerate:
GRAFANA_INFINITY_UID=cfzakgwkklxc0a node social/grafana/build-e2e-lifecycle-dashboard.mjsImport / refresh
- Grafana → Dashboards → New → Import → upload the JSON from
social/grafana/ - Map Infinity when prompted; overwrite if the UID already exists
- Or on the VPS:
git pullsosocial/grafana/provisioned/updates (file provider ~30s)
Do not put secrets in dashboard JSON — only on Infinity and platform Pages.
Troubleshooting — AI usage panels No data
A few panels empty, others fine, recovers on refresh (#1049). Every panel makes its own API request. ai-usage and cloudflare-billing now share one provider fetch between concurrent panel requests for the same date range, and keep a healthy result for 60 s, so one page load calls OpenAI and Cloudflare once instead of about 17 times. OpenAI 429 and 5xx responses are retried once. A response's X-Platform-Cache header shows miss, shared or hit. Payloads with a failing provider are never cached, and figures can be up to a minute old.
- Run
bash scripts/verify-grafana-platform-api.sh(from repo root, withCLOUDFLARE_API_TOKENfor the Pages check). For the live probe, export the same credentials Grafana Infinity uses:GRAFANA_CF_ACCESS_CLIENT_ID/GRAFANA_CF_ACCESS_CLIENT_SECRET, orcd terraform && terraform output -raw social_insights_service_token_client_id(and_client_secret).
- Interpret the result:
| Probe result | Fix |
|---|---|
401 UNAUTHORIZED | Infinity headers are stale or wrong — copy current values from terraform output into the Infinity datasource (must match Pages SOCIAL_INSIGHTS_CF_ACCESS_*). |
503 SOCIAL_INSIGHTS_AUTH_NOT_CONFIGURED | Pages missing service token env — run Platform admin Terraform (apply-platform-admin). |
| HTTP 200 but Grafana still empty | Inspect JSON workersAi.ok / openai.ok and message — provider keys may be missing (verify-platform-ai-usage-pages-env.sh) or date range has no usage. |
| 302 / HTML login on curl | Missing Zero Trust bypass or Pages middleware skip — see Access + Pages middleware above. |
Right token, still 401 (#1562). First check the header names. On 2026-11-11 every panel went empty because Cloudflare's edge began removing CF-Access-Client-Id and CF-Access-Client-Secret before the request reached the platform; the stored token was fine. A live log tail of the production deployment (wrangler pages deployment tail <deployment id> --project-name home-dashboard-platform --format json) shows which headers arrive. The token now travels as X-Lovely-Client-Id / X-Lovely-Client-Secret.
Stored secret out of step (#1005). If the header names are right and the probe, Grafana or a CI POST (E2E lifecycle, CI runner queue) still gets 401 with the right ed8df… ID, the secret stored on platform Pages may not match production Terraform state. A Terraform apply won't fix that, because Cloudflare doesn't return secret values, so no diff shows. Production state is the source of truth:
- Run the Platform refresh Grafana token Action (
confirm=refresh-grafana-token). It reads the token from production state (no apply), writesSOCIAL_INSIGHTS_CF_ACCESS_CLIENT_IDand_SECRETwhole ontohome-dashboard-platformproduction in one PATCH (scripts/set-platform-pages-grafana-token.mjs), retries the production deployment and waits until the live API answers 200 to the token (scripts/verify-platform-grafana-token-live.mjs). When it passes it posts a one-line note to Slack #workflows. - Grafana and the GitHub copies (
E2E_LIFECYCLE_CF_ACCESS_*) need no change when they already hold the state value: the hourly CI runner queue metrics run loggingjobs pushedproves the GitHub copy. Only if Grafana still gets 401 after step 1, resetX-Lovely-Client-Secreton the Infinity data source fromterraform output; if CI still gets 401, runnode scripts/sync-e2e-lifecycle-github-secrets.mjs.
Grafana's Save & test on the Infinity data source stays green with a wrong secret; trust a dashboard panel or the probe, not that button.
verify-platform-ai-usage-pages-env.shpassing only provesPLATFORM_CF_API_TOKEN+PLATFORM_OPENAI_ADMIN_KEYslots exist — it does not prove Grafana can authenticate. Always run the Grafana verify script when panels go red.
Sanity check (AI usage, manual curl)
curl -sS \
-H "X-Lovely-Client-Id: …" \
-H "X-Lovely-Client-Secret: …" \
"https://platform.lovely-home.co.uk/api/platform/ai-usage?from=$(date -v-7d +%Y-%m-%d 2>/dev/null || date -d '7 days ago' +%Y-%m-%d)&to=$(date +%Y-%m-%d)" \
| jq '{generatedAt, workersAi: {ok: .workersAi.ok, endCappedToNow: .workersAi.endCappedToNow, message: .workersAi.message}, openai: {ok: .openai.ok, error: .openai.error}, claude: {ok: .claude.ok, message: .claude.message}}'Expect generatedAt set, workersAi: true when Analytics Read is configured.
Running Grafana on the VPS (one Docker only, #1001)
Grafana used to run under snap Docker while everything else on the VPS (invoice app, cloudflared) ran under the regular apt Docker. Two daemons on one host fight over iptables and the docker0 bridge. When one recreates containers, the other's containers can lose outbound networking. That caused the 19 Oct 2026 outage, where every panel showed 504 (#1000).
scripts/vps/migrate-grafana-off-snap-docker.sh moves Grafana to the regular Docker. It rebuilds Grafana from the snap container's own docker inspect, so the image, ports, mounts, user and settings stay the same. Secrets from the container's environment go to /opt/grafana/grafana.env (mode 600), never into the compose file or the repo. On the VPS, from the repo checkout:
sudo bash scripts/vps/migrate-grafana-off-snap-docker.sh plan # read-only: shows both Dockers + the generated compose
sudo bash scripts/vps/migrate-grafana-off-snap-docker.sh migrate # back up, stop the old container (kept), start the new one, verify
# … check the dashboards in the browser …
sudo bash scripts/vps/migrate-grafana-off-snap-docker.sh retire-snap # disable snap Docker (data kept), restart Docker oncemigratebacks up every mount to/opt/grafana/backup-{time}/, copies named volumes into the regular Docker, and starts/opt/grafana/docker-compose.yml. It then checks/api/healthand that Grafana's container reaches the platform (expects 401).- Shared socket. If both daemons listen on
/var/run/docker.sock, both CLIs reach whichever daemon started last. The script compares daemon IDs and stops if both CLIs reach the same one. Find each socket withsudo ss -xlp | grep docker, then rerun withSNAP_DOCKER_HOST=unix://… TARGET_DOCKER_HOST=unix://…. - Snap Docker took over
docker.sock(the VPS on 20 Oct 2026).sudo ss -xlp | grep docker.sockshows the apt dockerd on an orphaned/run/docker.sockand the snap dockerd on a newer socket at/var/run/docker.sock, which is the same path. Everydockercommand then reaches snap Docker, and the apt daemon (invoice app) keeps running but can't be reached.planhas already saved what's needed, so:bashsudo snap stop --disable docker # Grafana stops; its data stays on disk sudo systemctl restart docker.socket docker # apt Docker owns the socket again (invoice app blips) sudo docker ps # should list the invoice app containers sudo bash scripts/vps/migrate-grafana-off-snap-docker.sh adoptadoptuses the saved plan, backs up the data volume from its directory, copies it into the regular Docker, starts Grafana and verifies it. Noretire-snapis needed afterwards. rollbackat any point stops the new Grafana and starts the old snap container again.retire-snaprefuses while snap Docker still has other containers. It runssystemctl restart dockerso the regular Docker owns the firewall rules again; the invoice app restarts for a few seconds. After a quiet week:sudo snap remove --purge docker.
Afterwards Grafana is managed with sudo docker compose -f /opt/grafana/docker-compose.yml … like everything else, and the 504 symptom in the table above shouldn't come back.
Grafana version and compose file (#1030)
Grafana's compose file lives in the repo: ops/grafana/docker-compose.yml, pinned to grafana/grafana:13.2.4. Its mounts are relative to the checkout (dashboards, provisioned JSON, alerting). Secrets stay on the VPS in /opt/grafana/grafana.env (mode 600; template: ops/grafana/grafana.env.example).
cd ~/home-dashboard && git pull
sudo docker compose -f ops/grafana/docker-compose.yml up -d # same project "grafana", same volume and portThis replaces /opt/grafana/docker-compose.yml from the migration; delete that file once the repo one is running. Keeping current: Dependabot (docker-compose ecosystem, Sundays 04:00 UK) opens a PR when a new Grafana is released. Read the release notes, merge, then run the two commands above on the VPS. A major version (14.x) can change dashboards or alerting, so take a backup first: sudo tar -C /var/lib/docker/volumes/grafana_grafana-data/_data -czf ~/grafana-$(date +%F).tgz .
Cost alerts (#1028)
Provisioned from social/grafana/provisioning/alerting/ (generated by GRAFANA_INFINITY_UID=cfzakgwkklxc0a node social/grafana/build-cost-alerts.mjs). The rules are evaluated hourly in the Lovely Home folder:
| Alert | Fires when | Source |
|---|---|---|
| Cloudflare bill over $10 this month | summary.totalCost > 10 | GET /api/platform/cloudflare-billing (current month; Billable Usage API lags ~1 day) |
| Workers AI over $10 this month | workersAi.summary.costUsd > 10 | GET /api/platform/ai-usage?period=month |
| OpenAI over $10 this month | openai.summary.costUsd > 10 | same; no data yet counts as OK |
| Claude over $15 this month | estimated_cost_usd of claude.summaryRows[period="this_month"] (1st of the UTC month to today, #1442) > 15 | GET /api/platform/ai-usage |
| GitHub Actions minutes over 75% / 90% of the free allowance | summary.percentOfIncluded > 75 / > 90 | GET /api/platform/github-actions-usage (month to date) |
| GitHub Actions is charging this month | summary.billedUsd > 0 | same |
Delivery: contact point Lovely Home ops, which sends email through Resend's SMTP and posts to Slack. One notification goes out when an alert fires, then a daily reminder while it stays over, then a resolved message. A failing API keeps the last state, so an outage doesn't page you. Set these in /opt/grafana/grafana.env, then run sudo docker compose -f ops/grafana/docker-compose.yml up -d:
| Variable | Value |
|---|---|
GF_SMTP_ENABLED, GF_SMTP_HOST, GF_SMTP_USER, GF_SMTP_FROM_ADDRESS, GF_SMTP_FROM_NAME, GF_SMTP_STARTTLS_POLICY | as in grafana.env.example (smtp.resend.com:587, user resend) |
GF_SMTP_PASSWORD | a Resend API key. A separate sending-only key for Grafana is best, so it can be revoked on its own. |
ALERT_EMAIL_TO | where alert emails go |
SLACK_ALERT_WEBHOOK_URL | a Slack incoming-webhook URL for the alerts channel |
What an alert says (#1314): each rule carries four annotations, and the contact point's email and Slack settings (SUBJECT_TEMPLATE / MESSAGE_TEMPLATE in the builder) turn them into the message. The wording sits inline in the contact point, not in a named notification template: Grafana's notifier only loads provisioned templates about a minute after start, and an email sent before then had an empty subject that Resend rejected (#1316). templates.json only deletes the old lovely-home template.
summary: what happened, with the number (for example "Claude has cost about $15.75 this month. The alert level is $15."). The resolved message reuses it, so it states the figure rather than "over the limit".why: why it matters.action: what to do.where: which Grafana dashboard to open.
The subject is "Lovely Home alert: {title}" while firing and "Back to normal: {title}" when resolved. Raw query values (A=15.75 B=1) and labels are no longer shown.
Test delivery: Alerting → Contact points → Lovely Home ops → Test. Edit the builder, not the JSON. Grafana expands $VAR in provisioning files except rule annotations, which it stores raw. So the builder writes literal dollars as $$ everywhere else (a $10 title would otherwise render 0) and leaves annotations alone, where $values must reach the template engine. Escaping annotations too is what made alerts show $${{ printf … $$values.A.Value }} until #1314. The subject and message contain no $ at all.
After changing alerts: on the VPS, git pull in ~/home-dashboard, then sudo docker compose -f ops/grafana/docker-compose.yml restart grafana (alerting provisioning is read at start-up). Grafana keeps a provisioned rule that is simply dropped from the file, so a removed or renamed rule's old uid goes in RETIRED_RULE_UIDS in the builder, which writes it to deleteRules (#1442 retired lh-cost-claude-30d).
File provisioning (VPS)
Provider: social/grafana/provisioning/dashboards/dashboards.yml (disableDeletion: true, updateIntervalSeconds: 30).
Mount:
social/grafana/provisioning/dashboards→/etc/grafana/provisioning/dashboardssocial/grafana/provisioned→/var/lib/grafana/dashboards
After changing dashboards.yml, restart Grafana. Prefer Import for one-off refreshes if Git sync is not mounted.
Platform CD note
Cloudflare Pages Platform CD does not update Grafana. After API or JSON changes: deploy platform Pages (for Functions), then re-import or pull provisioned JSON on the VPS.
Website visitors
Endpoint: GET /api/platform/social-insights?view=website-visitors&from=YYYY-MM-DD&to=YYYY-MM-DD · dashboard lovely-home-website-visitors (build: GRAFANA_INFINITY_UID=… node social/grafana/build-website-visitors-dashboard.mjs) · #1583.
It is a view of the social-insights path on purpose: that path already has the Grafana Zero Trust bypass and the Pages middleware skip, so no new Access app (Terraform) is needed. Without view the endpoint answers exactly as before.
- Source: Cloudflare Web Analytics (the cookie-free beacon on every marketing page), account GraphQL dataset
rumPageloadEventsAdaptiveGroups, filtered torequestHost = lovely-home.co.uk(override withWEBSITE_ANALYTICS_HOSTNAME) andbot = 0. Only real browsers count, so API calls, hub traffic, images and bots are left out. Code:functions/api/platform/platformWebsiteVisitors.js. - Needs
CLOUDFLARE_ACCOUNT_IDandPLATFORM_CF_API_TOKENwith Account → Analytics → Read (already set for AI usage). No zone id. - Visitors = Cloudflare
visits(a page view whose referrer is not this site). The site has no cookies, so there is no exact unique-people count. A visit belongs to the page it started on: per page, Visits started here is the landing count. - Pages add the 13 language URLs together (
/fr/pricing→/pricing, usingsplitMarketingLanguagePath); the collapsed More detail row lists every URL. - Referrers get friendly names (Google, Facebook, Instagram, ChatGPT …); in-site navigation is dropped.
- Sign-ups come from
getSignupFunnelfor the same range (same test-hub exclusions). Sign-ups per landing page are not possible: sign-up records do not store the landing page. - Long ranges are split by the dataset's
maxDuration(read fromsettings, 7 days if unknown); ranges older than Cloudflare keeps (notOlderThan) are clipped and Data status says so. - Responses are shared for 60 s per range (
withShortCache), so one dashboard load makes one Cloudflare read. - Empty panels: open More detail → Data status. It shows Cloudflare's own error, e.g. a missing permission.
Signup funnel
Endpoint: GET /api/platform/signup-funnel?from=YYYY-MM-DD&to=YYYY-MM-DD · dashboard lovely-home-signup-funnel (build: GRAFANA_INFINITY_UID=… node social/grafana/build-signup-funnel-dashboard.mjs).
Reads platform billing D1 only — no emails in the response. Excluded from every stage:
- lifecycle
e2e-*hubs; - every home of an internal test account (#1210).
INTERNAL_TEST_SITE_IDSinfunctions/api/platform/platformSignupFunnel.jslists the hubs (todaymulti, Mark's Multi Home test onmulti.lovely-hub.com); the funnel finds their owner insite_billing/account_homesand drops all of that owner's homes. Owner emails are only compared inside SQL, never returned.
| Stage | Source |
|---|---|
| Signup submitted | signup_attribution row written when a valid signup reserves its hub name (migration 0022_signup_attribution.sql) |
| Hub created | site_billing.created_at in range (Free at signup; Plus after Checkout) |
| Build started / failed | provision_dispatched_at / provision_last_error |
| Lovely Home+ / Multi | plan_tier = 'plus' or an account plan |
| Still active | status in active, trialing |
Campaigns. The marketing site copies utm_source, utm_medium, utm_campaign, utm_content and the landing path (lp) from the landing URL onto internal links (URL only — no cookies or storage), and /signup posts them as attribution. Untagged visits show as (direct).
Use case. /signup has an optional What’s it for? picker (house_sitting, pet_sitting, holiday_let, family, carers, house_share, just_me), pre-selected from ?use= or the sitter landing pages. It is stored in signup_attribution.use_case (migration 0023_signup_use_case.sql) and shown in the Signups by use case panels. The hub setup wizard reads it via GET /api/public/hub-signup-use-case (hub Origin CORS, like hub-trial-status) and pre-selects the matching hub use case — and therefore starter guide — when the owner has not saved one yet.
Free signups are not in Stripe, so the Stripe dashboard stays empty for them; use this one.
Rollout: apply migration 0022 (node scripts/apply-platform-billing-migration.mjs), merge for the Pages bypass, terraform apply platform_admin for the Access bypass app, then git pull on the VPS (provisioned JSON) or import the dashboard JSON.
CI runner queue (#998)
How long GitHub Actions jobs waited for a runner (job created → started), per pool: the lovely-home VPS, ubuntu-latest, and ubuntu-24.04 on the public orchestrator. The target from #847 is a self-hosted p95 under 10 min at signup peaks.
| Piece | Where |
|---|---|
| Collector | .github/workflows/ci-runner-queue-metrics.yml, hourly at :23 on lovely-home. It runs scripts/push-runner-queue-metrics.mjs over the last 3 h of runs in home-dashboard and lovely-hub-provision. |
| Store | ci_runner_queue_jobs on SOCIAL_INSIGHTS_DB (migration social/migrations/0017), upserted by job id and pruned after 90 days |
| API | GET /api/platform/ci-runner-queue?from=&to= returns pools (p50/p95/max/over_target), hourlySeries, slowestJobs and lastIngestAt. The collector uses POST on the same path. |
| Auth | Same service token. The workflow uses the E2E_LIFECYCLE_CF_ACCESS_* repo secrets. |
Rollout:
- Apply the social migration: Social — apply D1 migrations workflow, or
npm run social:migrate. - Deploy platform Pages, then run Platform admin Terraform (Access bypass app
platform_ci_runner_queue). - Run CI runner queue metrics once with
window_hours: 72to backfill. - Pull or import the dashboard JSON.
Last job recorded goes stale if the collector is failing. Check the workflow's warnings, which include the POST status. It can also look stale overnight when no CI ran.
Regenerate:
GRAFANA_INFINITY_UID=cfzakgwkklxc0a node social/grafana/build-ci-runner-queue-dashboard.mjsGitHub Actions usage (#1082)
GitHub Free includes 2,000 Actions minutes a month for private repos (home-dashboard, invoice-app, …), reset each billing cycle. Public repos (lovely-hub-provision) on standard runners and the VPS runner are free and never count. Beyond the allowance, Linux minutes cost $0.006 each.
- Data:
GET /api/platform/github-actions-usage(or?month=YYYY-MM) calls GitHub's billing usage API for the account and caches the result for 5 minutes. It splits rows into private and public repos and returnssummary(privateMinutes,percentOfIncluded,projectedPercentOfIncluded,publicMinutes,billedUsd),byRepoandbyDay. - Token: GitHub's billing usage endpoints only accept a classic personal access token. Put it in your local
hub.tfvarsasplatform_github_billing_token, then push it to GitHub withnode scripts/sync-hub-tfvars-to-github-secrets.mjs --repo marklovely/home-dashboard --profile provision(it becomes the secretPLATFORM_GITHUB_BILLING_TOKEN; the script never sends it to the public repo). Platform admin Terraform then sets it on platform Pages. An older secret namedGH_BILLING_TOKENalso works. A local apply without it inhub.tfvarsremoves it from Pages, as with the OpenAI key. Until then the endpoint returns{ "configured": false }and the panels are empty. - Optional Pages env:
PLATFORM_GITHUB_PUBLIC_REPOS(defaultlovely-hub-provision; add any other public repo),PLATFORM_GITHUB_INCLUDED_MINUTES(default 2000, use 3000 on GitHub Pro),PLATFORM_GITHUB_BILLING_USER(defaultmarklovely). - Dashboard: Lovely Home — GitHub Actions usage shows allowance used, private minutes, a month-end projection, the billed amount, public minutes (free), minutes per day and a per-repo table. Generate it with
GRAFANA_INFINITY_UID=cfzakgwkklxc0a node social/grafana/build-github-actions-usage-dashboard.mjs. - Alerts: at 75% and 90% of the allowance, and when anything is billed (see Cost alerts).
- Running low: set the repo variable
HUB_REGISTRY_RUNNER=self-hostedto move customer registry runs back to the VPS (platform-provision.md).