grafana / alloy

OpenTelemetry Collector distribution with programmable pipelines
https://grafana.com/oss/alloy
Apache License 2.0
1.45k stars 216 forks source link

The `cluster_name` label on `alloy_config_hash` has extra quotes around it #2134

Open petewall opened 5 days ago

petewall commented 5 days ago

What's wrong?

I give the alloy cluster a name with the Helm chart:

  alloy:
    clustering:
      name: alloy
      enabled: true

Which sets it as a command line arg:

spec:
  containers:
  - args:
    - run
    - /etc/alloy/config.alloy
    - --storage.path=/tmp/alloy
    - --server.http.listen-addr=0.0.0.0:12345
    - --server.http.ui-path-prefix=/
    - --cluster.enabled=true
    - --cluster.join-addresses=k8smon-alloy-cluster
    - --cluster.name="alloy"
    - --stability.level=generally-available

But the metric actually includes the quotes:

alloy_config_hash{
  cluster="test-cluster",
  cluster_name=""alloy"",         <--- extra quotes in the label value
  container="alloy",
  instance="10.244.0.35:12345",
  job="integrations/alloy",
  namespace="default",
  pod="k8smon-alloy-0",
  sha256="6afb9ff264d967bb48eec54fe76a63723c643f3eeb45b6dc532ecf8bb4e4fae7"
}

Steps to reproduce

Use the Alloy Helm chart to deploy Alloy with clustering and a cluster name.

System information

No response

Software version

No response

Configuration

Logs

dehaansa commented 2 days ago

Just tested this locally in a non-clustered, run from local build on osx and it doesn't occur, looks like it's the helm chart.

I went and looked at the containers/_agent.yaml file and saw that it was quoting the value

- --cluster.name={{ $values.clustering.name | quote }}

I changed it to not | quote and the quotes were gone. Tested with value with spaces, value with an attempt to break parsing, and it all worked, but I'm very very far from a k8s or helm expert. Does this make sense to you that it would work without | quote?

alloy:
    clustering:
      name: alloy cluster --cluster.name=fred
      enabled: true
alloy_config_hash{cluster_name="alloy cluster --cluster.name=fred",sha256="fbc28486b565e334d139908df7e3b9244f3c8de221d76cb3b489f38411825eeb"} 1