Skip to content

Commit

Permalink
Add support for specifying SSL config for influxdb output
Browse files Browse the repository at this point in the history
closes #191
  • Loading branch information
sparrc committed Feb 13, 2016
1 parent 8236534 commit 6a601ce
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 23 additions & 0 deletions plugins/outputs/influxdb/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ type InfluxDB struct {
Timeout internal.Duration
UDPPayload int `toml:"udp_payload"`

// Path to CA file
SSLCA string `toml:"ssl_ca"`
// Path to host cert file
SSLCert string `toml:"ssl_cert"`
// Path to cert key file
SSLKey string `toml:"ssl_key"`
// Use SSL but skip chain & host verification
InsecureSkipVerify bool

conns []client.Client
}

Expand All @@ -52,6 +61,13 @@ var sampleConfig = `
# user_agent = "telegraf"
### Set UDP payload size, defaults to InfluxDB UDP Client default (512 bytes)
# udp_payload = 512
### Optional SSL Config
# ssl_ca = "/etc/telegraf/ca.pem"
# ssl_cert = "/etc/telegraf/cert.pem"
# ssl_key = "/etc/telegraf/key.pem"
### Use SSL but skip chain & host verification
# insecure_skip_verify = false
`

func (i *InfluxDB) Connect() error {
Expand All @@ -66,6 +82,12 @@ func (i *InfluxDB) Connect() error {
urls = append(urls, i.URL)
}

tlsCfg, err := internal.GetTLSConfig(
i.SSLCert, i.SSLKey, i.SSLCA, i.InsecureSkipVerify)
if err != nil {
return err
}

var conns []client.Client
for _, u := range urls {
switch {
Expand Down Expand Up @@ -94,6 +116,7 @@ func (i *InfluxDB) Connect() error {
Password: i.Password,
UserAgent: i.UserAgent,
Timeout: i.Timeout.Duration,
TLSConfig: tlsCfg,
})
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion plugins/outputs/mqtt/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"strings"
"sync"

paho "git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.golang.git"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/outputs"
"github.com/influxdata/telegraf/plugins/serializers"

paho "git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.golang.git"
)

var sampleConfig = `
Expand Down

0 comments on commit 6a601ce

Please sign in to comment.