Skip to content

helm: add service_name relabel rule to alloy scrape config#5262

Open
SLoeuillet wants to merge 2 commits into
grafana:mainfrom
SLoeuillet:helm-alloy-service-name
Open

helm: add service_name relabel rule to alloy scrape config#5262
SLoeuillet wants to merge 2 commits into
grafana:mainfrom
SLoeuillet:helm-alloy-service-name

Conversation

@SLoeuillet

Copy link
Copy Markdown

What

Adds a relabel rule to the Helm chart's default Alloy scrape config that maps the profiles.grafana.com/service_name pod annotation to the service_name label:

rule {
    action        = "replace"
    source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_service_name"]
    target_label  = "service_name"
}

It sits alongside the existing service_repository / service_git_ref / service_root_path rules in templates/configmap-alloy.yaml.

Why

The chart already lets users set service_repository, service_git_ref and service_root_path via profiles.grafana.com/* annotations, but not service_name — the single most important label, used by the App Selector to identify an application (#2051).

Without it, Alloy falls back to inferring service_name from target metadata (namespace + app.kubernetes.io/*). When that inference is generic — e.g. a Helm component literally named default — pods surface under a useless/colliding service_name (<namespace>/default) with no annotation-based way to override it, unlike every other service_* label. This rule closes that gap so an operator can simply set profiles.grafana.com/service_name: my-app.

Behaviour / compatibility

  • No-op unless a pod sets the annotation. An explicit service_name label takes precedence over Alloy's inference, so existing deployments are completely unaffected until they opt in.
  • Consistent with the existing service_* annotation rules — same block, same placement.

Changes

  • templates/configmap-alloy.yaml — the new rule.
  • rendered/*.yaml — regenerated (the rule is in the static config block, so it appears identically in all six fixtures).
  • Chart.yaml / README.md — chart version 2.0.3 → 2.0.4 (appVersion unchanged).

Closes #2051

The default Alloy scrape config maps the profiles.grafana.com/service_repository,
service_git_ref and service_root_path annotations to labels, but not
service_name. Without an explicit service_name label, Alloy falls back to
inferring it from the target metadata (e.g. namespace + app.kubernetes.io
labels), which is often not what the user intends — a pod whose inferred name
is generic (a component literally named "default", etc.) shows up under a
useless service_name and cannot be overridden via annotation like the other
service_* labels can.

Add a relabel rule mapping profiles.grafana.com/service_name to the
service_name label, consistent with the existing service_repository /
service_git_ref / service_root_path rules. No-op unless a pod sets the
annotation, so existing deployments are unaffected. Regenerated rendered
manifests and bumped the chart version.

Closes grafana#2051

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Stephane Loeuillet <stephane.loeuillet@kaiko.com>
@SLoeuillet SLoeuillet requested a review from a team as a code owner June 17, 2026 07:57
@cla-assistant

cla-assistant Bot commented Jun 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cla-assistant

cla-assistant Bot commented Jun 17, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@cla-assistant

cla-assistant Bot commented Jun 17, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

Require presence of service_name in scrape configs

1 participant