[rancher-monitoring 69.8-rancher.27] Fix issues with metricRelabelings in exporters#156
[rancher-monitoring 69.8-rancher.27] Fix issues with metricRelabelings in exporters#156belgaied2 wants to merge 6 commits into
Conversation
Signed-off-by: Mohamed Belgaied Hassine <belgaied2@hotmail.com>
…core-dns, kube-controller-manager, etc. Signed-off-by: Mohamed Belgaied Hassine <belgaied2@hotmail.com>
|
holding merge until 2.12.4 - this is going to be a backport since its already fixed on 2.13 |
|
@susesamu Can we merge this? |
|
@skanakal no.. we still need to fix the bug that Deepak found here rancher/rancher#43392 (comment). @belgaied2 is taking a look. |
|
@deepakpunia-suse I am a bit confused about your findings, I just did the following:
ingressNginx:
enabled: true
namespace: ingress-nginx
service:
port: 9913
targetPort: 10254
serviceMonitor:
interval: 30s
metricRelabelings:
- action: drop
regex: kube_(daemonset|deployment|pod|namespace|node|statefulset).+
sourceLabels:
- __name__
proxyUrl: ''
relabelings: []
$ helm install -f values-qa.yaml rancher-monitoring-crd rancher-monitoring-crd-69.8.2-rancher.27.tgz
NAME: rancher-monitoring-crd
LAST DEPLOYED: Tue Dec 2 13:44:09 2025
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
$ helm upgrade --install -f values-qa.yaml rancher-monitoring --create-namespace -n cattle-monitoring-system rancher-monitoring-69.8.2-rancher.27.tgz
Release "rancher-monitoring" has been upgraded. Happy Helming!
NAME: rancher-monitoring
LAST DEPLOYED: Tue Dec 2 13:48:56 2025
NAMESPACE: cattle-monitoring-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
rancher-monitoring has been installed. Check its status by running:
kubectl --namespace cattle-monitoring-system get pods -l "release=rancher-monitoring"
Get Grafana 'admin' user password by running:
kubectl --namespace cattle-monitoring-system get secrets rancher-monitoring-grafana -o jsonpath="{.data.admin-password}" | base64 -d ; echo
Access Grafana local instance:
export POD_NAME=$(kubectl --namespace cattle-monitoring-system get pod -l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=rancher-monitoring" -oname)
kubectl --namespace cattle-monitoring-system port-forward $POD_NAME 3000
Visit https://github.com/prometheus-operator/kube-prometheus for instructions on how to create & configure Alertmanager and Prometheus instances using the Operator.
$ k get smon -n ingress-nginx rancher-monitoring-ingress-nginx -oyaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations:
meta.helm.sh/release-name: rancher-monitoring
meta.helm.sh/release-namespace: cattle-monitoring-system
creationTimestamp: "2025-12-02T12:51:57Z"
generation: 1
labels:
app: rancher-monitoring-ingress-nginx
app.kubernetes.io/instance: rancher-monitoring
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/part-of: rancher-monitoring
app.kubernetes.io/version: v0.80.1
chart: rancher-monitoring-69.8.2-rancher.27
helm.sh/chart: rancher-monitoring-69.8.2-rancher.27
heritage: Helm
release: rancher-monitoring
name: rancher-monitoring-ingress-nginx
namespace: ingress-nginx
resourceVersion: "24653"
uid: 4ec941de-09b3-474f-a742-59891ba80c66
spec:
endpoints:
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
interval: 30s
metricRelabelings:
- action: drop
regex: kube_(daemonset|deployment|pod|namespace|node|statefulset).+
sourceLabels:
- __name__
port: http-metrics
jobLabel: jobLabel
namespaceSelector:
matchNames:
- ingress-nginx
selector:
matchLabels:
app: rancher-monitoring-ingress-nginx
release: rancher-monitoringSo, everything seems to work for me. Can you please check ? |
|
Details: @belgaied2 It is still failing for me with the same error mentioned above. I noticed that you installed it using Helm, but it is failing specifically through the UI installation. Below are the exact steps and a screenshot of the process I followed using the UI. If you give this a try, you will likely face the same error.
|
…ding 2 spaces Signed-off-by: Mohamed Belgaied Hassine <belgaied2@hotmail.com>
Signed-off-by: Mohamed Belgaied Hassine <belgaied2@hotmail.com>
|
After further investigation, indeed there is a problem when the chart is installed with Rancher because of the following block: where the The fix, is to change the indentation to @deepakpunia-suse please check again against the latest version. Thanks! |
|
@belgaied2 We can see that the first installation attempt is failing with the error: Ideally, the UI installation should not require the customer to create a namespace manually. We need to add logic to create the namespace automatically if it does not already exist.
|






Issue:
rancher/rancher#43392
Solution
The
metricRelabelingsattribute inServiceMonitortakes in a list of maps coming from thevalues.yaml.In order to template that in helm, the previous implementation did the following :\
This does not work with multiline relabelings, such as:
which would generate:
AND throw an error!
We need to remove first space characters using
{{- tpl ...and do multiline indentation usingnindentinstead ofindent.That's what this PR does for each location of
metricRelabelingsin versions 106 and 107 of therancher-monitoringchart.Commit messages: