Skip to content

Enforce metric label cardinality budgets at registration and block runaway dimensions #348

@thlpkee20-wq

Description

@thlpkee20-wq

Description

Prometheus is fragile against high-cardinality labels. Add a registration wrapper that requires each metric to declare a cardinality budget and refuses new label combinations that would exceed it.

Requirements and context

  • Must be secure, tested, and documented
  • Should be efficient and easy to review
  • Relevant code: src/metrics.ts, src/metrics/slotMetrics.ts
  • Drop or relabel offenders to __overflow__

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b feat/metric-cardinality-budgets
  • Implement changes
    • Wrapper API requiring {name, labels, budget}
    • LRU map of seen label tuples per metric
    • Emit metric_cardinality_overflow_total counter
  • Validate security and correctness assumptions

Test and commit

  • Run tests
    • npm test
  • Cover edge cases
    • Budget set to 0 falls back to no-label aggregation
  • Include test output and notes

Example commit message

feat: metric label cardinality budgets

Guidelines

  • Minimum 95 percent test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend scopeobservabilityLogs, metrics, tracing, dashboardssecuritySecurity hardening and threat mitigation

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