Skip to content

Conversation

@fedeabih
Copy link
Contributor

@fedeabih fedeabih commented Sep 21, 2025

Add relabeling and metricRelabeling for all helm charts

This pull request updates all Helm charts to support feat-relabeling and metric relabeling.
It introduces new configuration options that allow users to customize relabeling rules for Prometheus metrics
across all charts in a consistent way.

Fix: #805

Checklist

  • I have read the contributing guidelines and signed the CLA.
  • I have referenced an issue containing the design document if my change introduces a new feature.
  • I have read the security policy.
  • I confirm that this pull request does not address a security vulnerability.
    If this pull request addresses a security vulnerability,
    I confirm that I got approval (please contact security@ory.sh) from the maintainers to push the changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added the necessary documentation within the code base (if appropriate).

Further comments

@fedeabih
Copy link
Contributor Author

Example:

values.yaml

serviceMonitor:
  # -- Relabeling is a powerful tool to dynamically rewrite the label set of a target before it gets scraped.
  # Reference: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
  relabelings:
  - source_labels: [__address__]
    regex: '([^:]+):.*'
    target_label: instance
    replacement: '$1'
  # -- Metric relabeling is applied to samples as the last step before ingestion.
  # Reference: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs
  metricRelabelings:
  - source_labels: [__address__]
    regex: '([^:]+):.*'
    target_label: instance
    replacement: '$1'

Output:

- 
+ # Source: keto/templates/servicemonitor-metrics.yaml
+ apiVersion: monitoring.coreos.com/v1
+ kind: ServiceMonitor
+ metadata:
+   name: keto-metrics
+   namespace: default
+   labels:
+     app.kubernetes.io/component: metrics
+     helm.sh/chart: keto-0.58.0
+     app.kubernetes.io/name: keto
+     app.kubernetes.io/instance: keto
+     app.kubernetes.io/version: "v0.14.0"
+     app.kubernetes.io/managed-by: Helm
+ spec:
+   endpoints:
+   - path: /metrics/prometheus
+     port: http-metrics
+     scheme: http
+     interval: 60s
+     scrapeTimeout: 30s
+     metricRelabelings:
+       - regex: ([^:]+):.*
+         replacement: $1
+         source_labels:
+         - __address__
+         target_label: instance
+     relabelings:
+       - regex: ([^:]+):.*
+         replacement: $1
+         source_labels:
+         - __address__
+         target_label: instance
+   selector:
+     matchLabels:
+       app.kubernetes.io/name: keto
+       app.kubernetes.io/instance: keto
+       app.kubernetes.io/component: metrics

@fedeabih fedeabih marked this pull request as ready for review September 25, 2025 20:09
Copy link
Collaborator

@Demonsthere Demonsthere left a comment

Choose a reason for hiding this comment

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

Hey there!
Some housekeeping before we can merge this :)

  1. Please create at least 1 new test values overrides file (in hacks/values/app) that will have some relabeling set, so that the CI can generate a serviceMonitor with the fields set
  2. Please run make helm-docs to update chart readme with the new values

@fedeabih
Copy link
Contributor Author

Hey there! Some housekeeping before we can merge this :)

  1. Please create at least 1 new test values overrides file (in hacks/values/app) that will have some relabeling set, so that the CI can generate a serviceMonitor with the fields set
  2. Please run make helm-docs to update chart readme with the new values

Hi! I followed your feedback, but instead of creating a new values override file, I added the relabeling example directly to the default values. Since the change is small and doesn’t introduce much complexity, I thought it might be simpler to keep it in the default file rather than maintaining an extra override file.

Would you be okay with that approach, or do you prefer that I still create a separate file under hacks/values/app?

Regards!

@Demonsthere
Copy link
Collaborator

I am ok with setting that in the default values :) I see that the CI fails when installing postgres 🤔 will check that when i can, as possibly the overrides needs to be updated for the db

@Demonsthere Demonsthere self-requested a review October 2, 2025 08:22
@Demonsthere Demonsthere merged commit 4f366b4 into ory:master Oct 2, 2025
21 checks passed
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.

Add relabeling and metricRelabeling to helm charts

2 participants