fluent-plugin-kafka icon indicating copy to clipboard operation
fluent-plugin-kafka copied to clipboard

environment variable usage in kafka_configs for rdkafka_group input

Open shyimo opened this issue 4 years ago • 5 comments
trafficstars

Is your feature request related to a problem? Please describe.

It seems like there is no way to pass environment variables for kafka_configs hash in rdkafka_group input. for example:

<source>
  @type  rdkafka_group
  @label @APPLICATIONS
  topics "#{ENV["APPLICATIONS_TOPIC"] || "application-logs"}"
  format "json"

  kafka_configs {
     "bootstrap.servers": "#{ENV["BROKER_ADDRESS"] || "localhost:9092"}"
  }

</source>

the bootstrap.servers will not parse the BROKER_ADDRESS environment variable.

Describe the solution you'd like

This will be great if there was a way to parse those environment variables inside the kafka_configs hash. At the current situation, we are not able to fully use all librdkafka features since hard coded values are not possible for some of the fields.

Describe alternatives you've considered

any parsing method that will able to get dynamic fields and not hard coded values

Additional context

No response

shyimo avatar Nov 15 '21 06:11 shyimo

Hmm, probably we need to modify fluentd core to realize it.

ashie avatar Nov 16 '21 00:11 ashie

@ashie i ended up doing this:

<source>
  @type  rdkafka_group
  @label @APPLICATIONS
  topics "#{ENV["APPLICATIONS_TOPIC"] || "application-logs"}"
  format "json"

  kafka_configs "#{ENV["KAFKA_CONFIGS"]}"
</source>

and when i run my docker the following:

docker run -e KAFKA_CONFIGS="bootstrap.servers:${KAFKA_BROKERS},group.id:${APPLICATIONS_GROUP_ID}"

the KAFKA_CONFIGS environment variable is parsed as hash object and this works.

shyimo avatar Nov 17 '21 12:11 shyimo

@shyimo it works to me. Super.

billzhuang avatar Jun 21 '22 08:06 billzhuang

Here is how I worked it out:

rdkafka_options "#{'{ "security.protocol": "sasl_ssl", "sasl.mechanisms": "SCRAM-SHA-512", "sasl.username": "%s", "sasl.password": "%s" }' % [ENV['MSK_USERNAME'], ENV['MSK_PASSWORD']]}"

sendbird-sehwankim avatar Feb 22 '23 01:02 sendbird-sehwankim