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

feat(keycloakx): make relabelings possible on serviceMonitors #815

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

Conversation

wilmardo
Copy link
Contributor

@wilmardo wilmardo commented Feb 5, 2025

Allow settings relabelings on the ServiceMonitors. My usecase is to show the pod names instead of the IPs in a dashboard and this is one of the easiest ways. Just add a relabel in the serviceMonitor.
For completeness I added the metricRelabelings as well.
But this is probably useful for other things is well, this PR just makes the existing fields available for the helm chart user.

Quick local test copy paste:

Values file:

serviceMonitor:
  enabled: true
  relabelings:
    - action: replace
      regex: (.*)
      sourceLabels: [__meta_kubernetes_pod_name]
      targetLabel: instance
  metricRelabelings:
    - action: drop
      regex: jvm_.+
      sourceLabels:
      - __name__

helm template test charts/keycloakx -f test.yml -s templates/servicemonitor.yaml

---
# Source: keycloakx/templates/servicemonitor.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: test-keycloakx-keycloakx
  namespace: default
  labels:
    helm.sh/chart: keycloakx-7.0.1
    app.kubernetes.io/name: keycloakx
    app.kubernetes.io/instance: test
    app.kubernetes.io/version: "26.0.7"
    app.kubernetes.io/managed-by: Helm
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: keycloakx
      app.kubernetes.io/instance: test
      app.kubernetes.io/component: http
  endpoints:
    - port: "http-internal"
      path: "/auth/metrics"
      scheme: http
      interval: 10s
      scrapeTimeout: 10s
      relabelings:
        - action: replace
          regex: (.*)
          sourceLabels:
          - __meta_kubernetes_pod_name
          targetLabel: instance
      metricRelabelings:
        - action: drop
          regex: jvm_.+
          sourceLabels:
          - __name__

@wilmardo wilmardo requested a review from a team as a code owner February 5, 2025 14:11
@wilmardo wilmardo force-pushed the make-relabelings-possible branch from ceb38dd to 8dfe6ab Compare February 5, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant