Skip to content

Add PostgreSQL observability telemetry exposure via ServiceMonitors#1808

Draft
DmytroPI-dev wants to merge 3 commits intofeature/database-controllersfrom
postgres-operator-monitoring
Draft

Add PostgreSQL observability telemetry exposure via ServiceMonitors#1808
DmytroPI-dev wants to merge 3 commits intofeature/database-controllersfrom
postgres-operator-monitoring

Conversation

@DmytroPI-dev
Copy link
Copy Markdown

@DmytroPI-dev DmytroPI-dev commented Apr 1, 2026

Description

Adds PostgreSQL observability telemetry exposure for PostgresCluster with operator-managed metrics Services and Prometheus ServiceMonitors for PostgreSQL and PgBouncer.

Key Changes

api/v4/postgresclusterclass_types.go
Added class-level observability configuration for PostgreSQL and PgBouncer metrics.

api/v4/postgrescluster_types.go
Added cluster-level disable-only observability overrides.

pkg/postgresql/cluster/core/cluster.go
Wired PostgreSQL and PgBouncer metrics Service and ServiceMonitor reconciliation into the PostgresCluster flow.
Made ServiceMonitor presence required by failing reconciliation when the CRD is unavailable.

pkg/postgresql/cluster/core/monitoring.go
Added feature resolution helpers.
Added builders and reconcilers for PostgreSQL/PgBouncer metrics Services.
Added builders and reconcilers for PostgreSQL/PgBouncer ServiceMonitors.

internal/controller/postgrescluster_controller.go
Added RBAC for monitoring.coreos.com/servicemonitors.

cmd/main.go
Registered Prometheus Operator monitoring/v1 types in the manager scheme.

internal/controller/suite_test.go
Registered Prometheus Operator monitoring/v1 types in the test scheme.

pkg/postgresql/cluster/core/monitoring_unit_test.go
Added unit tests for observability flag resolution and monitoring resource builders.

Testing and Verification

Added unit tests in pkg/postgresql/cluster/core/monitoring_unit_test.go for:

  • class/cluster observability enablement logic
  • PostgreSQL and PgBouncer metrics Service builders
  • PostgreSQL and PgBouncer ServiceMonitor builders

Related Issues

CPI-1853 - related JIRA ticket.

PR Checklist

  • Code changes adhere to the project's coding standards.
  • Relevant unit and integration tests are included.
  • Documentation has been updated accordingly.
  • All tests pass locally.
  • The PR description follows the project's guidelines.

@DmytroPI-dev DmytroPI-dev force-pushed the postgres-operator-monitoring branch from a1b796f to 976ecd1 Compare April 2, 2026 14:08
@DmytroPI-dev DmytroPI-dev changed the title Create ServiceMonitor and basic Grafana dashboard for metrics Add PostgreSQL observability telemetry exposure via ServiceMonitors Apr 2, 2026
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