Skip to content

Unable to kafka receiver username config value to "$ConnectionString" with confmap.unifyEnvVarExpansion feature gate enabled #10713

@ben-childs-docusign

Description

@ben-childs-docusign

Describe the bug

We have some config to connect to azure event hubs using the kafka receiver this requires us to set the user name to "$ConnectionString" per azure documentation:
https://learn.microsoft.com/en-us/azure/event-hubs/azure-event-hubs-kafka-overview#shared-access-signature-sas

Prior to this feature gate enabled we were able to do this by configuring the receiver as follows:

  config:
    receivers:
      kafka:
        auth:
          sasl:
            mechanism: PLAIN
            username: "$$ConnectionString"
          tls:
            insecure: false
        protocol_version: 1.0.0
        topic: metricstopic

With version 105 of the collector we get this error:

Error: failed to get config: cannot resolve the configuration: cannot convert the confmap.Conf: variable substitution using $VAR has been deprecated in favor of ${VAR} and ${env:VAR} - please update $ConnectionString or temporarily disable the confmap.unifyEnvVarExpansion feature gate
2024/07/23 21:58:26 collector server run finished with error: failed to get config: cannot resolve the configuration: cannot convert the confmap.Conf: variable substitution using $VAR has been deprecated in favor of ${VAR} and ${env:VAR} - please update $ConnectionString or temporarily disable the confmap.unifyEnvVarExpansion feature gate

Steps to reproduce

Configure kafka receiver as shown above (no need to even add it to a pipeline)

What did you expect to see?

The config is loaded successfully

What did you see instead?

The collector crashes on boot

What version did you use?

v0.105.0

What config did you use?

  config:
    receivers:
      kafka:
        auth:
          sasl:
            mechanism: PLAIN
            username: "$$ConnectionString"
          tls:
            insecure: false
        protocol_version: 1.0.0
        topic: metricstopic

Environment

Ubuntu 20.04 - go 1.21

Additional context

Does this regex need to be updated to allow for "$$" prefixed strings to be excluded? Or is there some other fix missing?

var regex = regexp.MustCompile(fmt.Sprintf(`\$%s`, regexp.QuoteMeta(str)))

Note that this PR proposes to fix this problem but I should have that fix since I'm using version 105:
#10560

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions