Add support for setting kafka client id (#4418)

This commit is contained in:
Rion
2018-07-13 13:53:56 -07:00
committed by Daniel Nelson
parent 0da94a1b3c
commit c8f00030dd
4 changed files with 27 additions and 0 deletions

View File

@@ -22,6 +22,9 @@ and use the old zookeeper connection method.
## Offset (must be either "oldest" or "newest")
offset = "oldest"
## Optional client id
# client_id = "my_client"
## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"

View File

@@ -17,6 +17,7 @@ import (
type Kafka struct {
ConsumerGroup string
ClientID string `toml:"client_id"`
Topics []string
Brokers []string
MaxMessageLen int
@@ -59,6 +60,9 @@ var sampleConfig = `
brokers = ["localhost:9092"]
## topic(s) to consume
topics = ["telegraf"]
## Optional Client id
# client_id = "Telegraf"
## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
@@ -114,6 +118,12 @@ func (k *Kafka) Start(acc telegraf.Accumulator) error {
return err
}
if k.ClientID != "" {
config.ClientID = k.ClientID
} else {
config.ClientID = "Telegraf"
}
if tlsConfig != nil {
log.Printf("D! TLS Enabled")
config.Net.TLS.Config = tlsConfig