postgres controllers metrics#1811
Draft
limak9182 wants to merge 2 commits intofeature/database-controllersfrom
Draft
postgres controllers metrics#1811limak9182 wants to merge 2 commits intofeature/database-controllersfrom
limak9182 wants to merge 2 commits intofeature/database-controllersfrom
Conversation
Contributor
|
CLA Assistant Lite bot: I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds comprehensive Prometheus metrics for the PostgreSQL controllers using a hexagonal
(ports & adapters) pattern — the domain code depends only on a
Recorderinterface, neveron Prometheus directly.
New package:
pkg/postgresql/metrics/ports.go—Recorderinterface + typed constants for all label values (controller names,result labels, error classes, action names, resource kinds). Compile-time checked, no magic
strings.
prometheus.go—PrometheusRecorderadapter: 13 metric families withsplunk_operator_postgres_prefix, registered against the controller-runtime metrics registry.noop.go—NoopRecorderfor unit tests.collector.go—FleetCollectorwith per-resource-type rate limiting (2s) to recomputefleet-state gauges from the informer cache after each reconcile.
Metrics emitted (13 families):
reconcile_totalreconcile_duration_secondsreconcile_errors_totalreconcile_requeues_totalvalidation_failures_totalclustersdatabasesmanaged_usersuser_actions_totalpoolerspooler_instancesfinalizer_operations_totalowned_resource_operations_totalThree-layer collection:
rc.Metrics.*calls in service code — next to existing event emissionsDesign decisions:
(
controller_runtime_reconcile_total{controller="postgresCluster|postgresdatabase"})controller,result,phase,reason) — noper-resource
name/namespacelabels, following Prometheus best practicesNoopRecorder) and adapter swappabilityports.go— typos become compile errorspkg/splunk/client/metrics/is untouchedKey Changes
Highlight the updates in specific files
Testing and Verification
Setting up Grafana + Prometheus on KIND
1. Install the monitoring stack
Open http://localhost:3000 — login: admin / admin
The Prometheus datasource is auto-configured. Query any metric with the splunk_operator_postgres_ prefix.
Related Issues
Jira tickets, GitHub issues, Support tickets...
PR Checklist