Skip to content

Commit 1095d68

Browse files
Yornikclaude
andauthored
feat(monitoring): use upstream-maintained CNPG dashboard, drop workarounds (#311)
Reverts the misdirected workaround stack from #309 and #310, replaces with the actual fix: load the upstream-maintained Grafana dashboard from cloudnative-pg/grafana-dashboards (the standalone dashboards repo, NOT the operator-chart-bundled snapshot). Background CNPG 1.27+ moved backup metric reporting from operator-emitted cnpg_collector_* into plugin-emitted barman_cloud_cloudnative_pg_io_* (plugin-barman-cloud 0.7.0+). The deprecated cnpg_collector_* metrics stay at 0 by design — they're not coming back. The operator's Helm chart (cloudnative-pg/charts) bundles a snapshot of the Grafana dashboard from before the rename. The standalone repo cloudnative-pg/grafana-dashboards has the maintained version with regex-based panel queries that match BOTH metric names: max({__name__=~"cnpg_collector_first_recoverability_point|barman_cloud_cloudnative_pg_io_first_recoverability_point", ...}) So loading the standalone-repo dashboard just works: it picks up our existing barman_cloud_* series (already flowing — verified 1779542651 unix timestamp matches the latest Backup CR's stoppedAt). Changes - Drop kube-state-metrics customResourceState block (#309 was working around a non-issue — the data is exposed under a different name, not missing). - Drop cnpg-backup-shim recording rules (#310 same reason). - Set cnpg-operator monitoring.grafanaDashboard.create=false so the chart-bundled stale dashboard is not created. - Add grafana.dashboards.default.cnpg-cluster URL pointer: pinned to commit 19f534b2 ("fix: support backup metrics from plugin-barman-cloud"), SHA256 integrity check. - Add Renovate customManager for raw.githubusercontent.com SHA pins so the dashboard SHA gets auto-tracked against the main branch of cloudnative-pg/grafana-dashboards. Pattern is generic — any future raw.githubusercontent.com pin in apps/values.yaml gets the same treatment. Net -21 lines across the two files. Upstream tracker for the chart dashboard not being synced with the standalone repo: filed/relevant issues are at cloudnative-pg/cloudnative-pg#7812, #8902, #10456 (all CLOSED — upstream considers the rename "done", chart-dashboard sync is not actively tracked). Co-authored-by: Claude Opus 4.7 <[email protected]>
1 parent 93e065b commit 1095d68

2 files changed

Lines changed: 30 additions & 51 deletions

File tree

‎apps/values.yaml‎

Lines changed: 15 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ apps:
7070
enabled: true
7171
datasources:
7272
enabled: true
73+
# URL-imported dashboards (chart's initContainer fetches at
74+
# Grafana pod startup, writes into the file-provider path).
75+
dashboards:
76+
default:
77+
cnpg-cluster:
78+
# Pinned to the commit that added barman_cloud_* support;
79+
# Renovate tracks via the customManager in renovate.json5.
80+
url: https://raw.githubusercontent.com/cloudnative-pg/grafana-dashboards/19f534b2b3d2d34e871d656351599eb8b170ad86/charts/cluster/grafana-dashboard.json
81+
sha256: 292cdeb3f17506d75623749fdfdfcaf51fbd9a414d6faa197434771fcff05bd2
7382
7483
# Prometheus
7584
prometheus:
@@ -103,23 +112,6 @@ apps:
103112
- record: namespace:container_memory_working_set:avg5m
104113
expr: sum by(namespace) (container_memory_working_set_bytes{container!=""})
105114
106-
# Synthesize the CNPG metrics the operator should populate in the
107-
# plugin model but doesn't (as of CNPG 1.29 + plugin-barman-cloud
108-
# v0.12.0). Aliases the kube-state-metrics customResourceState
109-
# gauge we expose from Backup CRs back to the upstream metric
110-
# names the CNPG Grafana dashboard already queries — so the panels
111-
# render without modifying dashboard JSON. Drop both rules once
112-
# upstream populates cnpg_collector_* directly.
113-
cnpg-backup-shim:
114-
groups:
115-
- name: cnpg-backup-shim
116-
interval: 30s
117-
rules:
118-
- record: cnpg_collector_last_available_backup_timestamp
119-
expr: max by(cluster) (kube_customresource_cnpg_backup_stopped_timestamp_seconds{phase="completed"})
120-
- record: cnpg_collector_first_recoverability_point
121-
expr: min by(cluster) (kube_customresource_cnpg_backup_stopped_timestamp_seconds{phase="completed"})
122-
123115
# Alertmanager
124116
alertmanager:
125117
alertmanagerSpec:
@@ -136,39 +128,6 @@ apps:
136128
extraArgs:
137129
- --no-collector.systemd
138130
139-
# Expose CNPG Backup.status.stoppedAt as a Prometheus metric so the
140-
# Grafana "last backup age" / RPO panels render. CNPG 1.29 + plugin-
141-
# barman-cloud v0.12.0 doesn't populate Cluster.status.* from the
142-
# plugin, leaving cnpg_collector_last_available_backup_timestamp at
143-
# 0. The Backup CRs themselves DO have .status.stoppedAt populated,
144-
# so we surface that via kube-state-metrics customResourceState.
145-
kube-state-metrics:
146-
rbac:
147-
extraRules:
148-
- apiGroups: ["postgresql.cnpg.io"]
149-
resources: ["backups"]
150-
verbs: ["get", "list", "watch"]
151-
customResourceState:
152-
enabled: true
153-
config:
154-
kind: CustomResourceStateMetrics
155-
spec:
156-
resources:
157-
- groupVersionKind:
158-
group: postgresql.cnpg.io
159-
version: v1
160-
kind: Backup
161-
metrics:
162-
- name: cnpg_backup_stopped_timestamp_seconds
163-
help: Unix timestamp when the CNPG Backup reached its stoppedAt time
164-
each:
165-
type: Gauge
166-
gauge:
167-
path: [status, stoppedAt]
168-
labelsFromPath:
169-
cluster: [spec, cluster, name]
170-
phase: [status, phase]
171-
172131
loki:
173132
namespace: monitoring
174133
helm:
@@ -782,7 +741,12 @@ apps:
782741
podMonitorAdditionalLabels:
783742
release: kube-prometheus-stack
784743
grafanaDashboard:
785-
create: true
744+
# Chart ships a stale dashboard snapshot that still queries
745+
# the deprecated cnpg_collector_* metrics. The maintained
746+
# dashboard at cloudnative-pg/grafana-dashboards queries both
747+
# the old AND new (barman_cloud_*) metric names. Load that
748+
# instead via grafana.dashboards URL pointer below.
749+
create: false
786750
prometheusRule:
787751
enabled: true
788752

‎renovate.json5‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,20 @@
101101
],
102102
datasourceTemplate: 'helm',
103103
},
104+
// Track SHA-pinned raw.githubusercontent.com URLs (e.g. the upstream
105+
// CNPG Grafana dashboard JSON we import at Grafana pod startup).
106+
// Renovate proposes PRs when the tracked branch advances.
107+
{
108+
customType: 'regex',
109+
managerFilePatterns: [
110+
'/apps/values\\.yaml$/',
111+
],
112+
matchStrings: [
113+
'https://raw\\.githubusercontent\\.com/(?<depName>[^/]+/[^/]+)/(?<currentDigest>[a-f0-9]{40})/',
114+
],
115+
currentValueTemplate: 'main',
116+
datasourceTemplate: 'github-refs',
117+
packageNameTemplate: '{{depName}}',
118+
},
104119
],
105120
}

0 commit comments

Comments
 (0)