This article explains how to enable monitoring for PolarDB-X databases in a K8s cluster.
Installing PolarDB-X Monitor
PolarDB-X utilizes Prometheus and Grafana to monitor PolarDB-X clusters. PolarDB-X Monitor integrates the kube-promethus stack, allowing one-click deployment of the necessary resources and components for monitoring by installing the PolarDB-X Monitor.
Prerequisites
- A running K8s cluster is already prepared, and ensure the cluster version is >= 1.18.0.
- Helm 3 has been installed.
- PolarDB-X Operator version 1.2.0 or higher has been installed.
Helm Package Installation
First, create a namespace named polardbx-monitor:kubectl create namespace polardbx-monitor
Install the PolarDBXMonitor CRD:
Note: If your PolarDB-X Operator 1.2.0 or higher was installed directly via helm install, the PolarDBXMonitor CRD is installed by default, and you can skip this step. If your PolarDB-X Operator was upgraded from version 1.1.0 or below using helm upgrade, you need to execute the following command to manually install it:
kubectl apply -f https://raw.githubusercontent.com/polardb/polardbx-operator/v1.6.2/charts/polardbx-operator/crds/polardbx.aliyun.com_polardbxmonitors.yaml
Execute the following command to install PolarDB-X Monitor:
helm install --namespace polardbx-monitor polardbx-monitor polardbx-monitor-1.6.2.tgz
You can also install it via the PolarDB-X Helm Chart repository:
helm repo add polardbx https://polardbx-charts.oss-cn-beijing.aliyuncs.com
helm install --namespace polardbx-monitor polardbx-monitor polardbx/polardbx-monitor
Note: Installing Prometheus and Grafana this way uses default configurations for quick trial. If deploying in a production cluster, you may refer to: Configure Prometheus + Grafana
Note: If you are installing PolarDB-X Monitor on minikube, you may encounter component creation issues due to insufficient resources. Please refer to: Configure Prometheus + Grafana
You should see the following output:
polardbx-operator monitor plugin is installed. Please check the status of components:
kubectl get pods --namespace {{ .Release.Namespace }}
Now start to monitor your polardbx cluster.
After the PolarDB-X Monitor installation is complete, components such as prometheus and grafana will be created within the polardbx-monitor namespace in your K8s cluster, to monitor PolarDB-X inside K8s. Check if the related components are functioning properly and confirm all pods are in Running status with the following command:
kubectl get pods -n polardbx-monitor