Enabling Monitoring for Existing Clusters
Monitoring data collection for the PolarDB-X Enterprise Edition is turned off by default and needs to be configured to enable it.
Enabling Monitoring for Existing PolarDB-X Enterprise Edition
This section explains how to enable monitoring for PolarDB-X Enterprise Edition clusters. Execute the following command to create a PolarDBXMonitor object for the PolarDBXCluster you wish to monitor:
kubectl apply -f polardbx-monitor.yaml
The yaml description of polardbx-monitor.yaml is as follows:
apiVersion: polardbx.aliyun.com/v1
kind: PolarDBXMonitor
metadata:
name: quick-start-monitor
spec:
clusterName: quick-start
monitorInterval: 30s
scrapeTimeout: 10s
- spec.clusterName: The name of the PolarDB-X cluster to enable monitoring for.
- spec.monitorInterval: The frequency of monitoring data collection, default is 30s.
- spec.scrapeTimeout: The timeout for monitoring data collection, default is 10s. Note: The value of scrapeTimeout must be less than monitorInterval.
Enabling Monitoring for Existing PolarDB-X Standard Edition
This section explains how to enable monitoring for PolarDB-X Standard Edition clusters. Execute the following command to configure a ServiceMonitor for your XStore object to enable monitoring:
kubectl apply -f polardbx-s-monitor.yaml
The content of polardbx-s-monitor.yaml is as follows:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
# Name of the ServiceMonitor object, you can define it yourself
name: polardbx-s-monitor
spec:
selector:
matchLabels:
# Name of the PolarDB-X Standard Edition (XStore) to enable monitoring for
xstore/name: polardbx-s
# Metrics service, no need to modify
xstore/service: metrics
# The following content uses default configuration and does not need to be modified
podTargetLabels:
- xstore/name
- xstore/role
endpoints:
- port: metrics
path: /metrics
interval: 30s
relabelings:
- sourceLabels: [xstore_name]
targetLabel: polardbx_name
- targetLabel: polardbx_role
replacement: "dn"
action: replace
Note: In the yaml file above, modify spec.selector.matchLabels.xstore/name and metadata.name to the name of the xstore object you want to enable monitoring for. Other contents do not need to be modified.