#18310·rook

Hardcoded cluster="<namespace>" ServiceMonitor relabeling conflicts with Prometheus externalLabels and breaks multi-cluster Ceph monitoring

Author: alirezasafiCreated Aug 31, 2026Updated Oct 1, 2026
Labelsbug

What happened

Since commit cc05619dd ("core: add cluster label to all servicemonitor scraped metrics"), the operator hardcodes a relabeling into every ServiceMonitor it creates (rook-ceph-mgr, rook-ceph-exporter):

go
RelabelConfigs: []monitoringv1.RelabelConfig{{
    TargetLabel: "cluster",
    Replacement: ptr.To(namespace),
}},

(pkg/operator/k8sutil/prometheus.go, GetServiceMonitor, present in v1.20.3/v1.20.6/master)

Every scraped Ceph metric is therefore stamped cluster="rook-ceph" (the operator namespace) at scrape time.

The problem

cluster is the conventional Prometheus label for identifying the site/Kubernetes cluster in multi-cluster monitoring (Prometheus externalLabels -> central VictoriaMetrics/Thanos/Mimir). Prometheus applies externalLabels only to samples that don't already carry the label — external labels never override. With several Kubernetes clusters, each running a rook-ceph cluster in the rook-ceph namespace and remote-writing to a central VictoriaMetrics:

  • Ceph metrics from all sites arrive with the identical cluster="rook-ceph" instead of the per-site external label (e.g. cluster="cluster-a.example.com", cluster="cluster-b.example.com")
  • series from different sites can't be distinguished, grouped, or filtered by cluster; dashboards and alerts that group by cluster aggregate across sites incorrectly or break entirely
  • the value duplicates the namespace label (also rook-ceph) and adds no information not already present via namespace/pod/instance

There is no way to disable or override it:

  • not exposed in CephCluster.spec.monitoring (MonitoringSpec has no related field)
  • manually patching the generated ServiceMonitors is reverted by the operator on every reconcile (CreateOrUpdateServiceMonitor)

Current workaround (per Prometheus, remote-write only — local data and dashboards stay broken):

yaml
remoteWrite:
- url: http://vminsert.../insert/0/prometheus/
  writeRelabelConfigs:
  - action: replace
    sourceLabels: [job]
    regex: rook-ceph-(mgr|exporter)
    targetLabel: cluster
    replacement: cluster-a.example.com

Desired behavior (any of)

  1. Make the label configurable via CephCluster.spec.monitoring (e.g. clusterLabel name+value, or a generic relabelings override, current behavior as default), or
  2. Use the CephCluster CR metadata.name (the clusterName value in the rook-ceph-cluster helm chart, e.g. cluster-a.example.com) as the replacement value instead of the namespace, falling back to the namespace when clusterName is not set — this preserves the current behavior for users who rely on defaults, while giving each Ceph cluster a distinct, user-controlled identity when configured (the operator already has the CR in hand at ServiceMonitor creation time), or
  3. Rename the injected label to a non-reserved name (e.g. rook_cluster) so it doesn't collide with the conventional cluster label, or
  4. Remove the hardcoded relabeling.

Environment

  • Rook: v1.20.3 and v1.20.6 (master 0707c2506)
  • Storage backend: Ceph v20.2.2
  • Kubernetes: multiple on-prem clusters, kube-prometheus-stack, remote write to central VictoriaMetrics