Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[prometheus-kube-stack] Unable to add metricRelabeling to additionalServiceMonitor #5120

Open
mehr74 opened this issue Jan 9, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@mehr74
Copy link
Contributor

mehr74 commented Jan 9, 2025

Describe the bug a clear and concise description of what the bug is.

When creating additional service monitors I am not able to add relabelings.

helm install kube-prometheus prometheus-community/kube-prometheus-stack -f values.yaml 
Error: INSTALLATION FAILED: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(ServiceMonitor.spec): unknown field "relabelings" in com.coreos.monitoring.v1.ServiceMonitor.spec

I am using the following values.

prometheus:
  additionalServiceMonitors:
    - name: test                          
      selector:
        matchLabels:
          app.kubernetes.io/name: test 
      namespaceSelector:
        matchNames:
          - test
      endpoints:
        - path: /metrics
          port: http
      relabelings:
      - sourceLabels: [__meta_kubernetes_pod_node_name]
        separator: ;
        regex: ^(.*)$
        targetLabel: nodename
        replacement: $1
        action: replace

The generated serviceMonitor seems to be invalid.

# Source: kube-prometheus-stack/templates/prometheus/servicemonitors.yaml
apiVersion: v1
kind: List
items:
  - apiVersion: monitoring.coreos.com/v1
    kind: ServiceMonitor
    metadata:
      name: test
      namespace: default
      labels:
        app: kube-prometheus-stack-prometheus
        
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/instance: test
        app.kubernetes.io/version: "66.4.0"
        app.kubernetes.io/part-of: kube-prometheus-stack
        chart: kube-prometheus-stack-66.4.0
        release: "test"
        heritage: "Helm"
    spec:
      
      endpoints:
        - path: /metrics
          port: http
      namespaceSelector:
        matchNames:
        - test
      selector:
        matchLabels:
          app.kubernetes.io/name: test
      relabelings:
        - action: replace
          regex: ^(.*)$
          replacement: $1
          separator: ;
          sourceLabels:
          - __meta_kubernetes_pod_node_name
          targetLabel: nodename

relabeling should be under endpoints and the correct template should look like the following:

# Source: kube-prometheus-stack/templates/prometheus/servicemonitors.yaml
apiVersion: v1
kind: List
items:
  - apiVersion: monitoring.coreos.com/v1
    kind: ServiceMonitor
    metadata:
      name: test
      namespace: default
      labels:
        app: kube-prometheus-stack-prometheus
        
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/instance: test
        app.kubernetes.io/version: "66.4.0"
        app.kubernetes.io/part-of: kube-prometheus-stack
        chart: kube-prometheus-stack-66.4.0
        release: "test"
        heritage: "Helm"
    spec:
      
      endpoints:
        - path: /metrics
          port: http
          relabelings:
            - action: replace
              regex: ^(.*)$
              replacement: $1
              separator: ;
              sourceLabels:
              - __meta_kubernetes_pod_node_name
              targetLabel: nodename

      namespaceSelector:
        matchNames:
        - test
      selector:
        matchLabels:
          app.kubernetes.io/name: test

What's your helm version?

version.BuildInfo{Version:"v3.8.2", GitCommit:"6e3701edea09e5d55a8ca2aae03a68917630e91b", GitTreeState:"clean", GoVersion:"go1.17.5"}

What's your kubectl version?

kubectl version [9:42:27] Client Version: v1.28.4 Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3 Server Version: v1.27.1

Which chart?

prometheus-community/kube-prometheus-stack

What's the chart version?

66.4.0

What happened?

No response

What you expected to happen?

No response

How to reproduce it?

No response

Enter the changed values of values.yaml?

No response

Enter the command that you execute and failing/misfunctioning.

helm install kube-prometheus prometheus-community/kube-prometheus-stack -f values.yaml

Anything else we need to know?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant