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 amonitoring.pgmonitor.exporter section to your PostgresCluster spec to activate the metrics sidecar.
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 aqueries.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 underconfig/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
Configure Prometheus scraping
The referenceprometheus.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.
OpenTelemetry metrics (alpha)
PGO supports exporting metrics via an OpenTelemetry collector sidecar as an alternative to the pgMonitor exporter. This path is controlled by theOpenTelemetryMetrics feature gate, which is disabled by default (alpha stage).
When enabled, configure the collector using spec.instrumentation:
crunchy-otel-collector scrape job that selects pods with the label postgres-operator.crunchydata.com/crunchy-otel-collector=true.
Next steps
Resize cluster resources
Adjust CPU, memory, and storage after initial deployment.
Feature gates reference
Enable alpha and beta features including OpenTelemetry metrics.