--- # Manually-managed PodMonitor for the knoe-db CNPG cluster. # # Replaces the deprecated spec.monitoring.enablePodMonitor + # spec.monitoring.podMonitorRelabelings fields in knoe-db.yaml (both flagged # for removal by the CNPG operator; see queue #13 in docs/TODO.md). # # The relabeling rule injects a `cluster` label on every scraped sample, # sourced from the cnpg.io/cluster pod label. The CNPG Grafana dashboards # filter every panel by `cluster="$cluster"`, so without this relabel only # 2 of 85 CNPG metrics (the operator-collector ones) render. # # Apply alongside knoe-db.yaml: # kubectl apply -f deploy/gcp/gke/knoe-db-podmonitor.yaml apiVersion: monitoring.coreos.com/v1 kind: PodMonitor metadata: name: knoe-db namespace: knoe-db-0 labels: # Match the label selector used by kube-prometheus-stack's Prometheus # instance so this PodMonitor is picked up automatically. release: kps spec: selector: matchLabels: cnpg.io/cluster: knoe-db podMetricsEndpoints: - port: metrics relabelings: - sourceLabels: ["__meta_kubernetes_pod_label_cnpg_io_cluster"] targetLabel: cluster action: replace