Skip to content

feat: Add crossplane_managed_resource_* state metrics#308

Open
lkiii wants to merge 1 commit intocrossplane-contrib:masterfrom
lkiii:add-state-metrics
Open

feat: Add crossplane_managed_resource_* state metrics#308
lkiii wants to merge 1 commit intocrossplane-contrib:masterfrom
lkiii:add-state-metrics

Conversation

@lkiii
Copy link

@lkiii lkiii commented Jan 28, 2026

Description of your changes

Add Prometheus state metrics for all managed resource types following the Crossplane observability guide.

Metrics exposed:

  • crossplane_managed_resource_exists - Count of existing managed resources
  • crossplane_managed_resource_ready - Count of ready managed resources
  • crossplane_managed_resource_synced - Count of synced managed resources

Each metric is labeled with GVK (GroupVersionKind). Polls every 30 seconds.

Implementation:

  • Added pkg/controller/statemetrics.go with SetupStateMetrics() function
  • Registers MRStateRecorder for all 22 managed resource types (PostgreSQL, MySQL, MSSQL - both cluster and namespaced)
  • Added unit tests in pkg/controller/statemetrics_test.go

Fixes #307

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

  • All unit tests pass (make reviewable)
  • Manual end-to-end testing verified metrics are exposed correctly at :8080/metrics
  • Created a test Database resource and confirmed crossplane_managed_resource_exists incremented from 0 to 1 after the 30-second poll interval

Add Prometheus state metrics for all managed resource types following
the Crossplane contribution guide for provider observability.

Metrics exposed:
- crossplane_managed_resource_exists
- crossplane_managed_resource_ready
- crossplane_managed_resource_synced

Each metric is labeled with GVK. Polls every 30 seconds.

Signed-off-by: Lukas Ignatavičius <lukas@cashcoach.ai>
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.

feat: Add crossplane_managed_resource_* state metrics

1 participant