Add support for setting kafka client id (#4418)
This commit is contained in:
@@ -10,6 +10,9 @@ This plugin writes to a [Kafka Broker](http://kafka.apache.org/07/quickstart.htm
|
||||
## Kafka topic for producer messages
|
||||
topic = "telegraf"
|
||||
|
||||
## Optional client id
|
||||
# client_id = "my_client"
|
||||
|
||||
## Optional topic suffix configuration.
|
||||
## If the section is omitted, no suffix is used.
|
||||
## Following topic suffix methods are supported:
|
||||
|
||||
@@ -25,6 +25,8 @@ type (
|
||||
Brokers []string
|
||||
// Kafka topic
|
||||
Topic string
|
||||
// Kafka client id
|
||||
ClientID string `toml:"client_id"`
|
||||
// Kafka topic suffix option
|
||||
TopicSuffix TopicSuffix `toml:"topic_suffix"`
|
||||
// Routing Key Tag
|
||||
@@ -68,6 +70,9 @@ var sampleConfig = `
|
||||
brokers = ["localhost:9092"]
|
||||
## Kafka topic for producer messages
|
||||
topic = "telegraf"
|
||||
|
||||
## Optional Client id
|
||||
# client_id = "Telegraf"
|
||||
|
||||
## Optional topic suffix configuration.
|
||||
## If the section is omitted, no suffix is used.
|
||||
@@ -186,6 +191,12 @@ func (k *Kafka) Connect() error {
|
||||
}
|
||||
config := sarama.NewConfig()
|
||||
|
||||
if k.ClientID != "" {
|
||||
config.ClientID = k.ClientID
|
||||
} else {
|
||||
config.ClientID = "Telegraf"
|
||||
}
|
||||
|
||||
config.Producer.RequiredAcks = sarama.RequiredAcks(k.RequiredAcks)
|
||||
config.Producer.Compression = sarama.CompressionCodec(k.CompressionCodec)
|
||||
config.Producer.Retry.Max = k.MaxRetry
|
||||
|
||||
Reference in New Issue
Block a user