open-telemetry / opentelemetry-collector

OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
4.43k stars 1.46k forks source link

Value containing `{` or `}` won't able to pass via `$${1}` #10613

Closed charz closed 3 months ago

charz commented 3 months ago

Describe the bug

I'm able to pass $${1} to value In v0.96.0, but it's not allow in v0.104.0 (maybe it was failed in the earlier version?). Is possible to add { and } in value?

$ ./otelcol-contrib --config=file:a.yaml --config=file:metric.yaml
Error: failed to resolve config: cannot resolve the configuration: environment variable "1" has invalid name: must match regex ^[a-zA-Z_][a-zA-Z0-9_]*$
2024/07/15 12:20:14 collector server run finished with error: failed to resolve config: cannot resolve the configuration: environment variable "1" has invalid name: must match regex ^[a-zA-Z_][a-zA-Z0-9_]*$

$ ./otelcol-contrib --version
otelcol-contrib version 0.104.0

$ cat metric.yaml
processors:
  metricstransform:
    transforms:
      - include: ^([^s_].*)$
        match_type: regexp
        action: update
        new_name: "unknown_metric"
        operations:
          - action: add_label
            new_label: name
            new_value: "$${1}"

Steps to reproduce

Here is the configuration file, and just run ./otelcol-contrib --config=file:a.yaml --config=file:metric.yaml

$ cat metric.yaml
processors:
  metricstransform:
    transforms:
      - include: ^([^s_].*)$
        match_type: regexp
        action: update
        new_name: "unknown_metric"
        operations:
          - action: add_label
            new_label: name
            new_value: "$${1}"

$ car a.yaml
receivers:
  statsd:
    endpoint: "127.0.0.1:8125" # default
    aggregation_interval: 15s  # default
    enable_simple_tags: true
    enable_metric_type: false
    is_monotonic_counter: true
    timer_histogram_mapping:
      - statsd_type: "histogram"
        observer_type: "histogram"
        histogram:
          max_size: 50
      - statsd_type: "timing"
        observer_type: "summary"
      - statsd_type: "distribution"
        observer_type: "histogram"
        histogram:
          max_size: 50

exporters:
  prometheus:
    endpoint: "0.0.0.0:9102"
    send_timestamps: false
    metric_expiration: 120m
    enable_open_metrics: true
    add_metric_suffixes: false
    resource_to_telemetry_conversion:
      enabled: true

processors:
  batch:

service:
  telemetry:
    logs:
      level: info
    metrics:
      address: ":8889"
  pipelines:
    metrics:
      receivers: [statsd]
      processors: [batch, metricstransform]
      exporters: [prometheus]

What did you expect to see? The $${1} should able to pass to value.

What did you see instead? It works in v0.96.0.

What version did you use? version: v0.104.0

Environment OS: Mac Compiler(if manually compiled): go 1.21

Additional context None

mx-psi commented 3 months ago

Thanks for reporting! This was fixed by open-telemetry/opentelemetry-collector#10560 and will be released in the next version. On v0.104.0 and v0.103.0 you can disable the confmap.unifyEnvVarExpansion feature gate to work around this by passing the --feature-gates=-confmap.unifyEnvVarExpansion command line option.

Let me know if that makes sense to you, thanks!

charz commented 3 months ago

Thanks for reporting! This was fixed by open-telemetry/opentelemetry-collector#10560 and will be released in the next version. On v0.104.0 and v0.103.0 you can disable the confmap.unifyEnvVarExpansion feature gate to work around this by passing the --feature-gates=-confmap.unifyEnvVarExpansion command line option.

Let me know if that makes sense to you, thanks!

Cool! thanks! I'll use --feature-gates=-confmap.unifyEnvVarExpansion for my current binary.

mx-psi commented 3 months ago

We believe this to be fixed in v0.105.0. If you still find issues related to this, please comment and I can reopen

cloudchristina commented 2 months ago

Hi @mx-psi I disabled the confmap.unifyEnvVarExpansion, however, still not working. May I ask if it works for you?

mx-psi commented 2 months ago

@cloudchristina what version of the Collector are you using?

cloudchristina commented 2 months ago

Hi @mx-psi I have tried v0.96.0, v0.104.0, v0.107.0

TylerHelmuth commented 2 months ago

@cloudchristina try v0.108.0, thats the latest version when the module is stable.

cloudchristina commented 2 months ago

Thank you @TylerHelmuth , I have just redeployed with v0.108.0, but seems still not working. Below is my chart.yml, the rest is the same as: https://github.com/aws-observability/terraform-aws-observability-accelerator/tree/main/modules/eks-monitoring. Can you help me check?

apiVersion: v2
name: opentelemetry
description: A Helm chart to install otel operator
type: application
version: 0.68.1
appVersion: 0.108.0

Below is the error

Screenshot 2024-09-04 at 12 50 25 AM
TylerHelmuth commented 2 months ago

@cloudchristina see https://github.com/open-telemetry/opentelemetry-operator/issues/3262. The operator is the common factor, there is something weird happening when the operator does the install.

TylerHelmuth commented 2 months ago

But also in that screen shot it shows you are using the ADOT collector, which we are not in control of and cannot help with.