Prometheus Cluster Label Configuration¶
This document explains how to modify Prometheus (CR) to add a cluster label (cluster_name
) to monitoring metrics, improving the readability of metrics and alert messages.
Method 1: Modify Prometheus Directly¶
-
Run the following command to locate the Prometheus (CR):
Expected output example:
-
Edit the Prometheus CR and add
cluster_name
under thespec.externalLabels
parameter. This value should match the registered cluster name in container management.
Method 2: Modify via Helm (Recommended)¶
-
It is recommended to update the
Prometheus CR
via Helm to avoid losing these configurations during upgrades. Edit the relevant parameters invalues.yaml
: -
Alternatively, you can set the value using the
--set
flag:
Additional Notes¶
Starting from container management v0.27, the cluster name is also recorded in the kpanda-system
namespace under the label kpanda.io/cluster-name
.
apiVersion: v1
kind: Namespace
metadata:
finalizers:
- kpanda.io/kpanda-system
labels:
kpanda.io/cluster-name: kpanda-global-cluster
kpanda.io/kube-system-id: deb65d24-1090-40cf-b5e6-489fac2f2c1b
kubernetes.io/metadata.name: kpanda-system
name: kpanda-system
name: kpanda-system
spec:
finalizers:
- kubernetes
status:
phase: Active