diff --git a/plugins/outputs/influxdb/influxdb.go b/plugins/outputs/influxdb/influxdb.go index c11484a48..52fd8039b 100644 --- a/plugins/outputs/influxdb/influxdb.go +++ b/plugins/outputs/influxdb/influxdb.go @@ -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 } @@ -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 { @@ -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 { @@ -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 diff --git a/plugins/outputs/mqtt/mqtt.go b/plugins/outputs/mqtt/mqtt.go index efa20944b..d28a04d72 100644 --- a/plugins/outputs/mqtt/mqtt.go +++ b/plugins/outputs/mqtt/mqtt.go @@ -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 = `