Skip to content

Commit

Permalink
Added SASL options for ouput kafka plugin (influxdata#2721)
Browse files Browse the repository at this point in the history
  • Loading branch information
seuf authored and jeichorn committed Jul 24, 2017
1 parent 7e80763 commit f327e43
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ be deprecated eventually.

### Features

- [#2721](https://github.com/influxdata/telegraf/pull/2721): Added SASL options for kafka output plugin.
- [#2723](https://github.com/influxdata/telegraf/pull/2723): Added SSL configuration for input haproxy.
- [#2494](https://github.com/influxdata/telegraf/pull/2494): Add interrupts input plugin.
- [#2094](https://github.com/influxdata/telegraf/pull/2094): Add generic socket listener & writer.
Expand Down
4 changes: 4 additions & 0 deletions plugins/outputs/kafka/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ This plugin writes to a [Kafka Broker](http://kafka.apache.org/07/quickstart.htm
## Use SSL but skip chain & host verification
# insecure_skip_verify = false
## Optional SASL Config
# sasl_username = "kafka"
# sasl_password = "secret"
data_format = "influx"
```

Expand Down
15 changes: 15 additions & 0 deletions plugins/outputs/kafka/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ type Kafka struct {
// Skip SSL verification
InsecureSkipVerify bool

// SASL Username
SASLUsername string `toml:"sasl_username"`
// SASL Password
SASLPassword string `toml:"sasl_password"`

tlsConfig tls.Config
producer sarama.SyncProducer

Expand Down Expand Up @@ -92,6 +97,10 @@ var sampleConfig = `
## Use SSL but skip chain & host verification
# insecure_skip_verify = false
## Optional SASL Config
# sasl_username = "kafka"
# sasl_password = "secret"
## Data format to output.
## Each data format has its own unique set of configuration options, read
## more about them here:
Expand Down Expand Up @@ -129,6 +138,12 @@ func (k *Kafka) Connect() error {
config.Net.TLS.Enable = true
}

if k.SASLUsername != "" && k.SASLPassword != "" {
config.Net.SASL.User = k.SASLUsername
config.Net.SASL.Password = k.SASLPassword
config.Net.SASL.Enable = true
}

producer, err := sarama.NewSyncProducer(k.Brokers, config)
if err != nil {
return err
Expand Down

0 comments on commit f327e43

Please sign in to comment.