Zabbix Template for CloudNativePG (CNPG) Backups Monitoring on Kubernetes
Automatic discovery of PostgreSQL CNPG clusters, backup monitoring, failure alerts, and backup age thresholds.
This Zabbix template provides full monitoring of CloudNativePG (CNPG) backups through the Kubernetes API, with no custom scripts required on cluster nodes.
- Kubernetes cluster hosting multiple CNPG databases across several namespaces.
- Zabbix Agent deployed as a DaemonSet for classic node/pod monitoring.
- This template extends monitoring by adding:
- Automatic discovery of CNPG clusters and backups,
- Detailed backup checks (status, failures, age),
- Using only the Kubernetes API (HTTP Agent).
- Discover & Monitor CloudNativePG (CNPG) PostgreSQL scheduled backups on Kubernetes
- Full Zabbix 7.x integration
- Automatic discovery (LLD) of CNPG clusters
- Backup status (completed / failed / running)
- Backup age monitoring with configurable threshold
- Zero agents or scripts on Kubernetes nodes
- API-only monitoring for maximum reliability
Backups are discovered via Kubernetes API:
GET /apis/postgresql.cnpg.io/v1/backups
Automatically extracted fields:
{#NS}→ CNPG namespace{#CL}→ CNPG cluster name
Optional filtering with {$CNPG.NS.FILTER} → in example, to filter namespaces starting with cnpg-*.
For each discovered CNPG cluster:
-
cnpg.backup.last_status[{#NS},{#CL}]
Last known backup status (completed,failed,started,unknown, …) -
cnpg.backup.age[{#NS},{#CL}]
Age (in seconds) of the last successful backup, or0if none has ever succeeded.
For each cluster:
- ❌ Backup FAILED — status not
completedorstarted. ⚠️ Backup too old — age exceeds{$CNPG.BACKUP.MAXAGE}.⚠️ No successful backup found — nocompletedbackup exists.
- Kubernetes:
v1.34 - Zabbix Server / Frontend:
7.0.16 - CloudNativePG:
ghcr.io/cloudnative-pg/cloudnative-pg:1.27.1
- The default RBAC from zabbix helm chart do allow zabbix to request postgresql.cnpg.io API.
- We need to fix this :
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: zabbix-cnpg-backup-reader
rules:
- apiGroups: ["postgresql.cnpg.io"]
resources: ["backups", "scheduledbackups"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: zabbix-cnpg-backup-reader
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: zabbix-cnpg-backup-reader
subjects:
- kind: ServiceAccount
name: zabbix-service-account
namespace: monitoringTo retrieve your zabbix token, use this command:
kubectl -n <NAMESPACE> create token zabbix-service-accountUse it in macro: {$KUBE.API.TOKEN}.
Configuration → Templates → Import
Import:
template_cnpg_backups_api.json
- Choose your existing "Kube API hosts" and assign it the template.
- If you d'ont already have a host to monitor your kubernetes cluster using the API, create a new one an set the macros below.
- Macros to configure:
| Macro | Description |
|---|---|
{$KUBE.API.URL} |
Kubernetes API URL |
{$KUBE.API.TOKEN} |
ServiceAccount token |
| Macro | Description | Default |
|---|---|---|
{$CNPG.BACKUP.MAXAGE} |
Max age of last successful backup | 604800 |
{$CNPG.NS.FILTER} |
Filter schedule discovery. Optional | `` |
- Backup items visible in Latest data
- Alerts appear in Problems for failures/age/no-success
Example of Lastest data
Issues & PRs are welcome.
Distributed under the MIT License.
See the LICENSE file.

