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] Fix relabeling and metricRelabeling for additional serviceMonitor #5133

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mehr74
Copy link

@mehr74 mehr74 commented Jan 10, 2025

What this PR does / why we need it

The current kube-prometheus-stack does not allow relabeling and metricRelabeling for additional service monitors. The issue is that, these values are not placed under endpoint and we get the following error.

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

The MR moves metricRelabeling and relabeling under endpoint. To test the helm chart one can use 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

Which issue this PR fixes

Special notes for your reviewer

Checklist

  • DCO signed
  • Chart Version bumped
  • Title of the PR starts with chart name (e.g. [prometheus-couchdb-exporter])

@mehr74
Copy link
Author

mehr74 commented Jan 10, 2025

Hi @jkroepke,

Thanks a lot for your feedback on the code here. I forgot to sign-off last commit in my last branch. Could you please review once again?

@@ -21,6 +21,15 @@ items:
{{- if .jobLabel }}
jobLabel: {{ .jobLabel }}
{{- end }}
{{- if .metricRelabelings }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for another review here. But I take note here this result into a invalid YAML, if jobLabel is defined above.

Also it may leads into unexpected results, if endpoints contains multiple endpoint items.

Since the relabelings config can be part of the endpoints config as well. I think removing the 2 options would be the best possible option here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants