Skip to content

Add a /api/metrics protected by METRICS_AUTH_TOKEN with prom-client #159

Description

@greatest0fallt1me

Description

This is a backend issue for the GrantFox campaign. Expose /api/metrics protected by a bearer token specified via env, scraped by Prometheus.

Requirements and Context

  • Token required header
  • prom-client registry
  • Default Node metrics
  • Custom counters/histograms
  • Must be secure, tested, and documented
  • Should be efficient and easy to review

Suggested Execution

  1. Fork the repo and create a branch
    git checkout -b task/metrics-auth
  2. Implement changes
    • src/routes/metrics.ts (new)
    • src/metrics/registry.ts (new)
  3. Test and commit
    • Run the repo's standard test suite and lint
    • Cover edge cases; include output in the PR

Example commit message

feat: token-protected /api/metrics

Acceptance Criteria

  • Auth required
  • Defaults exposed
  • Custom metrics
  • Doc updated

Guidelines

  • Minimum 90% test coverage on changed lines
  • Input validation at the boundary; standardized error envelope
  • Structured logging with correlation IDs
  • Clear documentation and inline comments
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    GRANTFOX OSSGrantFox open-source campaign taskOFFICIAL CAMPAIGNOfficial GrantFox campaign issueapiAPI endpoint/contract workbackendBackend service worksecuritySecurity hardening

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions