Grafana Dashboards
Two curated Grafana Dashboards for monitoring Alauda CloudNativePG (CNPG) clusters, built on the CNPG built-in metrics exporter:
static/grafana/cluster-overview.json— cluster health: instance status, primary identity, replication lag, connections, transactions per second, cache hit ratio, storage and WAL usage (24 panels).static/grafana/backup-monitoring.json— continuous-backup health: time since last successful backup, backup failure indicator, point-in-time-recovery window, WAL archiving rate and backlog, WAL volume (15 panels).
Both dashboards were validated against a live 2-instance CNPG cluster on Alauda Container Platform (barman-cloud plugin backups to object storage, pgbench workload): every panel query verified to return data from the platform Prometheus.
TOC
The built-in exporter vspostgres-exporterWhat the exporter exposesInstall1. Create a PodMonitor with the platform-required label2. Point Grafana at the platform Prometheus3. Import the dashboardsPanel-to-metric mapKnown limitationsThe built-in exporter vs postgres-exporter
If you are coming from the Zalando-based PostgreSQL stack, monitoring
used a separate postgres-exporter sidecar. CNPG embeds an exporter
in every instance pod (port 9187) — nothing extra to deploy:
Do not attach postgres-exporter to a CNPG cluster — you would
duplicate scrapes and still lack the operator-level health metrics. If
you depended on pg_stat_user_tables / pg_stat_statements panels,
port those queries into a customQueriesConfigMap (the query YAML
dialect is essentially the same); rename dashboard series from pg_*
to cnpg_pg_*.
What the exporter exposes
- Native metrics (
cnpg_collector_*): instance up, PostgreSQL version, fencing, manual-switchover-required, nodes used, sync replica counts, WAL segment counts/sizes, WAL archive status (ready/done), and (PG ≥ 14) WAL write/sync statistics. - Default queries (
cnpg_<query>_*, from the operator-managedcnpg-default-monitoringConfigMap):backends,pg_database,pg_replication,pg_replication_slots,pg_stat_archiver,pg_stat_bgwriter/pg_stat_checkpointer,pg_stat_database,pg_stat_replication,pg_settings,pg_extensions. - Plugin metrics: CNPG-i plugins publish through the same endpoint.
The barman-cloud plugin (the backup method shipped with this product)
exposes
barman_cloud_cloudnative_pg_io_last_available_backup_timestamp,..._last_failed_backup_timestampand..._first_recoverability_point.
With plugin-managed backups, the legacy
cnpg_collector_last_available_backup_timestamp /
..._first_recoverability_point metrics stay 0 — they read in-tree
status fields the plugin does not set. The backup dashboard queries the
plugin series first and falls back to the in-tree ones, so it works with
plugin, volume-snapshot, and legacy in-tree barman backups alike.
Install
1. Create a PodMonitor with the platform-required label
The exporter is always on; what you must add is a PodMonitor so the
platform Prometheus scrapes it. On Alauda Container Platform the
platform Prometheus (kube-prometheus-0 in cpaas-system) selects
monitors in all namespaces, but only those carrying the label
prometheus: kube-prometheus:
spec.monitoring.enablePodMonitor: true on the Cluster also works but
is deprecated in CNPG 1.29 and generates a PodMonitor without the
required label — if you use it, propagate the label through
spec.inheritedMetadata.labels.
Verify the scrape:
2. Point Grafana at the platform Prometheus
Grafana ≥ 9.x with a Prometheus datasource.
The ACP Prometheus services
(kube-prometheus-0-web.cpaas-system.svc:9090 and the Thanos query
service) sit behind an OAuth (dex) proxy — a plain-URL datasource
receives redirects, not data. Either configure the datasource with an
Authorization: Bearer <platform id_token> custom HTTP header, or for
a Grafana running inside the cluster, target the Prometheus container
port directly (port 9090 on the prometheus-kube-prometheus-0-0 pod
is not proxied; the OAuth sidecar only fronts the service target port).
3. Import the dashboards
UI: Dashboards → New → Import → Upload JSON file — download
cluster-overview.json and
backup-monitoring.json, pick your
Prometheus datasource when prompted. Both dashboards expose namespace
and cluster template variables (discovered from cnpg_collector_up),
so one import covers every CNPG cluster on the platform.
Panel-to-metric map
Backup size is intentionally absent: CNPG does not export it as a
metric. Read it from the Backup resource status
(kubectl get backup <name> -o jsonpath='{.status}') or from the object
store; the Database size / WAL on disk panels serve as capacity
proxies.
Known limitations
pg_stat_replication-based panels only produce data on a primary with at least one streaming replica — on a 1-instance cluster they are legitimately empty.- Backup-freshness panels cover the barman-cloud plugin and in-tree methods; other backup plugins would need their series added.
- Grafana itself is not shipped by the CNPG plugin; bring your own (validated with Grafana 9.5).