Alerting
Important
Alerting for the Cennso Database extension requires the Prometheus OperatorOpens in a new tab.
The Cennso Database extension provides a pre-configured PrometheusRuleOpens in a new tab that allows the alerting system to monitor backup jobs for your MySQL and PostgreSQL database instances. The rule is installed as part of the cennso-db-support Helm chart, which can be deployed when you install the extension package.
You can disable the PrometheusRule using either Cennso Management Console (CMC) or CLI:
To disable the PrometheusRule, go to Cennso Management → Packages, click on the Cennso DB Extension package, and click Update. In the configuration form, find the PrometheusRules Enabled field and toggle it off.
To disable the PrometheusRule, set prometheusRule.enabled to false in the ClusterInstallation configuration:
Note
You can configure values of the Cennso Database Support chart. For more information about the available configuration options, see the Cennso Database Support chart reference.
The following alert rules are included:
- XtraBackupJobFailed - monitors backup pod failures for all MySQL database instances
- PgBasebackupJobFailed - monitors backup pod failures for all PostgreSQL database instances
Alert rules
This section lists the available alert rules that you can use for your Cennso Database instances.
XtraBackupJobFailed
The XtraBackupJobFailed alert fires when any XtraBackup backup pod enters the Failed phase.
The alert monitors all Kubernetes pods whose names match the xtrabackup-* prefix. This prefix is derived from the naming convention used by the DBBackup composition, which creates backup CronJobs named xtrabackup-{BACKUP-CLAIM-NAME}. Because the alert uses this naming convention rather than a specific claim name, it automatically covers all DBBackup instances deployed to your cluster, including those deployed after the package was installed.
The alert has the following properties:
When this alert fires, check the following:
Find the failing pod on the Core Cluster:
bashCheck the pod logs for the failure reason:
bashVerify that a MySQL replica pod is running. The backup job picks the first pod of the instance that is not the primary, with the same selector as the following command:
bashIf the command lists no pod, or the pod is not
RunningandReady, the backup cannot run. Check theDBInstanceand itsPerconaServerMySQLresource.
For more information on configuring backup jobs, see the Cennso Database Backup document.
PgBasebackupJobFailed
The PgBasebackupJobFailed alert fires when any PostgreSQL backup pod enters the Failed phase.
The alert monitors all Kubernetes pods whose names match the pg-basebackup-* prefix. This prefix is derived from the naming convention used by the PostgreSQLBackup composition, which creates backup CronJobs named pg-basebackup-{POSTGRESQLBACKUP-NAME}. Because the alert uses this naming convention rather than a specific resource name, it automatically covers all PostgreSQLBackup resources deployed to your cluster, including those deployed after the package was installed.
The alert has the following properties:
When this alert fires, check the following:
Find the failing pod on the cluster that runs the PostgreSQL instance:
bashCheck the pod logs for the failure reason:
bashVerify that a read replica of the target
PostgreSQLInstanceis ready. The backup job picks a ready replica pod with the same selector as the following command:bashIf the command lists no pod, or the pod is not
RunningandReady, the backup cannot run. APostgreSQLInstancewith a single replica has no read replica at all. The job also rejects a replica that does not stream from the primary or lags behind it by more than spec.maxReplicationLagBytes. In such a case, you can see an error in the logs.Verify that the restic repository from spec.resticRepository is reachable with the credentials from spec.credentialsSecretRef. The pod log shows the restic error when it is not. To check the credentials and the repository from your machine, load the
exportlines of the Secret into your shell and list the snapshots:bashAdd the same flags as spec.additionalResticOpts.backupExtraArgs for a repository with a self-signed certificate. A repository that is only reachable from inside the cluster cannot be checked this way. Instead, run the backup manually and follow its log:
bashDelete the Job afterwards, since it is not covered by the history limits of the CronJob:
bash
Custom alert rules
In addition to the pre-configured alert rules, you can define your own alert rules in two places:
- In the
cennso-db-supportchart, with the prometheusRule.additionalRules option. The chart creates one PrometheusRule on the Management Cluster, where the chart is installed, regardless of where the database clusters run. The rules are not tied to a single database cluster. The Prometheus or ruler that loads this PrometheusRule evaluates rules against all the metrics it can see, so one rule can cover every database cluster. - In each database cluster, with the spec.metricsExporter.prometheusRules option of the
DBInstanceandPostgreSQLInstanceCRs. The rules are installed separately for each database cluster, on the Kubernetes cluster where the database cluster runs, in the same namespace as the database cluster.
Choose the place based on where your alerting system loads PrometheusRule resources from. For example, a central rulerOpens in a new tab that runs on the Management Cluster can evaluate the metrics of several Core Clusters but load PrometheusRule resources only from the Management Cluster. Such a ruler does not see the rules created on the Core Clusters. In this case, use the chart option.
Rules in the cennso-db-support chart
To add your own rules to the PrometheusRule of the cennso-db-support chart, fill prometheusRule.additionalRules in the ClusterInstallation configuration. The chart adds the rules to the PrometheusRule as a separate group named cennso-db-additional.rules. The rules are installed only when prometheusRule.enabled is true.
The following example adds alerts that fire when a MySQL server uses more than its allowed number of connections. It defines two alerting rules with different thresholds:
- 80% threshold applies to all MySQL clusters except the one identified by the
mysql_instancelabel. - 90% threshold applies only to the MySQL cluster identified by the
mysql_instancelabel.
The first rule excludes the labelled MySQL cluster, while the second rule selects only this cluster:
Several rules can have the same alert name. Make sure that their expressions do not select the same MySQL server.
The chart copies the rules without changes, so you can use Prometheus template variables such as {{ $labels.pod }} in annotations as they are. Both alerting and recording rules are supported.
The chart rules are evaluated against all metrics the alerting system can see. If the alerting system collects metrics from several clusters, add a label matcher to each expression to specify the clusters you want to monitor.
Rules per database cluster
To define alert rules based on the metrics of a single database cluster, use the spec.metricsExporter.prometheusRules configuration option of the DBInstance and PostgreSQLInstance CRs. To do that, set the spec.metricsExporter.prometheusRules.enabled to true and fill the spec.metricsExporter.prometheusRules.rules with your custom Prometheus rules.
The following example shows a custom alert rule for a MySQL cluster:
The following example shows a custom alert rule for a PostgreSQL cluster:
The rules are created as one PrometheusRule per database cluster in the namespace set by spec.namespace:
These rules do not depend on the prometheusRule.enabled option of the cennso-db-support chart. For more information, see the following documents:
- Enable metrics collector for MySQL clusters
- Enable metrics collector for PostgreSQL clusters