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

v2: how to use dynamic variable in extraconfig #1199

Closed
khjean opened this issue Feb 4, 2025 · 2 comments
Closed

v2: how to use dynamic variable in extraconfig #1199

khjean opened this issue Feb 4, 2025 · 2 comments

Comments

@khjean
Copy link

khjean commented Feb 4, 2025

k8s-monitoring chart version : 2.0.4

I m using extraconfig in alloy-singleton for scraping rule
but i don't know how to use dynamic variable in extraconfig
this is my values.yaml
when i render values.yaml , "{{ $.Values.cluster.name }}" can not render to dynamic values

if you have a solution let me know ( when i use v1 , I had no problem )

...
  alloy-singleton:
    enabled: true
    alloy:
      enableReporting: false
    extraConfig: |-
      mimir.rules.kubernetes "default" {
          address = "{{ .Values.address}}"
          tenant_id = "anonymous"
          mimir_namespace_prefix = "{{ $.Values.cluster.name }}"
          rule_selector {
              match_labels = {
                  rule_group = "lgtm_group",
              }
          }
      }
...
@petewall
Copy link
Collaborator

In v1, extraConfig could contain Helm template directives, but in v2 it does not. It really got in the way of extraConfig for Loki rules, which also can contain {{ ... }} strings.

The way I'd do it would be to set those values as environment variables on the Alloy instance, then use sys.env to access them. Or, throw the in a ConfigMap, add a remote.kubernetes.configmap component, and access them with that.

@khjean
Copy link
Author

khjean commented Feb 17, 2025

oh ok! Thank you for your help

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

No branches or pull requests

2 participants