Skip to main content
PGO integrates with pgMonitor to give you production-grade observability for your PostgreSQL clusters. When enabled, the operator injects a crunchy-postgres-exporter sidecar into each instance pod. That sidecar exposes PostgreSQL metrics on port 9187 in Prometheus format, which Prometheus can scrape and Grafana can visualize using pre-built dashboards.

Enable the exporter

Add a monitoring.pgmonitor.exporter section to your PostgresCluster spec to activate the metrics sidecar.
The exporter field accepts the following options.

ExporterSpec fields

Set resource limits

Add custom queries

To extend the default query set with your own SQL, create a ConfigMap containing a queries.yml file and reference it via configuration.
The AppendCustomQueries feature gate (alpha, disabled by default) allows you to append custom queries to the default pgMonitor query set rather than replacing them. See Feature Gates for how to enable it.

Deploy Prometheus, Grafana, and Alertmanager

PGO ships a reference monitoring stack under config/monitoring/ in the operator repository. It deploys Prometheus, Grafana, and Alertmanager into a namespace using Kustomize.
1

Clone or download the monitoring config

The monitoring configuration lives at config/monitoring/ in the postgres-operator repository.
2

Set the target namespace

Open config/monitoring/kustomization.yaml and confirm the namespace field matches where you want to deploy the monitoring stack.
3

Apply the configuration

If you are deploying on OpenShift, comment out the fsGroup line under securityContext in alertmanager/deployment.yaml, grafana/deployment.yaml, and prometheus/deployment.yaml before applying.

Configure Prometheus scraping

The reference prometheus.yml included in the monitoring config already contains the correct scrape job for the pgMonitor exporter. It selects pods using the label postgres-operator.crunchydata.com/crunchy-postgres-exporter=true, which PGO automatically applies to every exporter pod.
Prometheus requires a service account with permission to list and watch pods in the namespaces where your clusters run.

OpenTelemetry metrics (alpha)

PGO supports exporting metrics via an OpenTelemetry collector sidecar as an alternative to the pgMonitor exporter. This path is controlled by the OpenTelemetryMetrics feature gate, which is disabled by default (alpha stage). When enabled, configure the collector using spec.instrumentation:
The reference Prometheus config includes a separate crunchy-otel-collector scrape job that selects pods with the label postgres-operator.crunchydata.com/crunchy-otel-collector=true.
See Feature Gates for full details on enabling OpenTelemetryMetrics and the related OpenTelemetryLogs gate.

Next steps

Resize cluster resources

Adjust CPU, memory, and storage after initial deployment.

Feature gates reference

Enable alpha and beta features including OpenTelemetry metrics.