Skip to content

Commit

Permalink
Add support for self-signed certs to InfluxDB input plugin (influxdat…
Browse files Browse the repository at this point in the history
  • Loading branch information
ljagiello authored and Vladislav Mugultyanov (Lazada Group) committed May 30, 2017
1 parent cf51bc4 commit fab4826
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

### Release Notes
### Features

- [#2773](https://github.com/influxdata/telegraf/pull/2773): Add support for self-signed certs to InfluxDB input plugin

### Bugfixes

- [#2749](https://github.com/influxdata/telegraf/pull/2749): Fixed sqlserver input to work with case sensitive server collation.
Expand Down
10 changes: 10 additions & 0 deletions plugins/inputs/influxdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ InfluxDB-formatted endpoints. See below for more information.
urls = [
"http://localhost:8086/debug/vars"
]

## 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

## http request & header timeout
timeout = "5s"
```

### Measurements & Fields
Expand Down
21 changes: 21 additions & 0 deletions plugins/inputs/influxdb/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ import (

type InfluxDB struct {
URLs []string `toml:"urls"`
// 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

Timeout internal.Duration

Expand All @@ -37,6 +45,13 @@ func (*InfluxDB) SampleConfig() string {
"http://localhost:8086/debug/vars"
]
## 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
## http request & header timeout
timeout = "5s"
`
Expand All @@ -48,9 +63,15 @@ func (i *InfluxDB) Gather(acc telegraf.Accumulator) error {
}

if i.client == nil {
tlsCfg, err := internal.GetTLSConfig(
i.SSLCert, i.SSLKey, i.SSLCA, i.InsecureSkipVerify)
if err != nil {
return err
}
i.client = &http.Client{
Transport: &http.Transport{
ResponseHeaderTimeout: i.Timeout.Duration,
TLSClientConfig: tlsCfg,
},
Timeout: i.Timeout.Duration,
}
Expand Down

0 comments on commit fab4826

Please sign in to comment.