Skip to content

feat(metrics): add keeperhub-metrics-collector service + image#1437

Closed
chong-techops wants to merge 1 commit into
stagingfrom
feature/TECH-6484-collector-service
Closed

feat(metrics): add keeperhub-metrics-collector service + image#1437
chong-techops wants to merge 1 commit into
stagingfrom
feature/TECH-6484-collector-service

Conversation

@chong-techops
Copy link
Copy Markdown

What

Adds keeperhub-metrics-collector, a standalone single-replica service that serves the DB-sourced Prometheus gauges (the former /api/metrics/db scrape) off the request-serving pods, plus its container image wiring. This is the service + image half of TECH-6484; the deploy wiring is a separate, dependent PR.

Approach

Executor-style: build-context = repo root, reuses lib/metrics + lib/db verbatim via tsx (zero query duplication, zero schema drift). import "server-only" is a no-op under Node/tsx (and shimmed in the image). Single replica → the scrape becomes deterministic from one pod, replacing the reverted hashmod idea.

  • keeperhub-metrics-collector/node:http server (PORT, default 9090) serving GET /metrics (updateDbMetricsgetDbMetrics) and GET /health; server.test.ts exercises the HTTP wiring on an ephemeral port.
  • Dockerfile metrics-collector stage — depends on source only (no Next builder): the metrics import graph references no builder-generated file at runtime (lib/db/schema uses lib/types/integration only via import type, erased by tsx).
  • docker-bake.hcl target/group + METRICS_COLLECTOR_ECR_REPO var.

Validation

  • pnpm type-check clean, pnpm check (biome) clean, collector tests pass (4).
  • Built the image (docker build --target metrics-collector): no Next build runs, prometheus-api + db-metrics import cleanly in the trimmed container, /health → 200, and /metrics constructs and runs the real aggregate queries (only the DB connection fails under a dummy URL — no missing modules).

Safe to merge anytime

Nothing builds or deploys this image yet — it's inert until the deploy PR + ECR repo land. No cutover here; the app's /api/metrics/db and its ServiceMonitor are untouched.

…6484 A)

Standalone single-replica service that serves the DB-sourced Prometheus
gauges (the former /api/metrics/db scrape) off the request-serving pods.
Executor-style: build-context = repo root, reuses lib/metrics + lib/db
verbatim via tsx, so the exposed gauge families are identical.

- keeperhub-metrics-collector/: node:http server (PORT 9090) serving GET
  /metrics (updateDbMetrics -> getDbMetrics) and GET /health, with a test
  exercising the HTTP wiring on an ephemeral port.
- Dockerfile metrics-collector stage (source-only dep, no Next builder) +
  source-stage wiring. Validated by a real image build: imports resolve,
  /health 200, /metrics runs the real queries.
- docker-bake.hcl target/group + METRICS_COLLECTOR_ECR_REPO var.

Inert until a deploy workflow + ECR repo wire it (TECH-6484 B).
@chong-techops
Copy link
Copy Markdown
Author

Consolidated into #1439 (service + image + deploy in one PR, now that the ECR repos exist so the split is no longer needed). Closing in favor of #1439.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

🧹 PR Environment Cleaned Up

The PR environment has been successfully deleted.

Deleted Resources:

  • Namespace: pr-1437
  • All Helm releases (Keeperhub, Scheduler, Event services)
  • PostgreSQL Database (including data)
  • LocalStack, Redis
  • All associated secrets and configs

All resources have been cleaned up and will no longer incur costs.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

ℹ️ No PR Environment to Clean Up

No PR environment was found for this PR. This is expected if:

  • The PR never had the deploy-pr-environment label
  • The environment was already cleaned up
  • The deployment never completed successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant