Added response_timeout property

closes #2006
This commit is contained in:
Pierre Tessier 2016-11-07 11:34:02 -05:00 committed by Cameron Sparr
parent 08f03ceba2
commit 6f9de7ab3d
3 changed files with 19 additions and 2 deletions

View File

@ -28,6 +28,7 @@ in their config file.
- [#2001](https://github.com/influxdata/telegraf/pull/2001): MongoDB input plugin: Improve state data. - [#2001](https://github.com/influxdata/telegraf/pull/2001): MongoDB input plugin: Improve state data.
- [#2078](https://github.com/influxdata/telegraf/pull/2078): Ping input: add standard deviation field. - [#2078](https://github.com/influxdata/telegraf/pull/2078): Ping input: add standard deviation field.
- [#2121](https://github.com/influxdata/telegraf/pull/2121): Add GC pause metric to InfluxDB input plugin. - [#2121](https://github.com/influxdata/telegraf/pull/2121): Add GC pause metric to InfluxDB input plugin.
- [#2006](https://github.com/influxdata/telegraf/pull/2006): Added response_timeout property to prometheus input plugin.
### Bugfixes ### Bugfixes

View File

@ -13,6 +13,17 @@ Example for Kubernetes apiserver
urls = ["http://my-kube-apiserver:8080/metrics"] urls = ["http://my-kube-apiserver:8080/metrics"]
``` ```
Specify a 10 second timeout for slower/over-loaded clients
```toml
# Get all metrics from Kube-apiserver
[[inputs.prometheus]]
# An array of urls to scrape metrics from.
urls = ["http://my-kube-apiserver:8080/metrics"]
# Specify timeout duration for slower prometheus clients (default is 3s)
response_timeout = "10s"
```
You can use more complex configuration You can use more complex configuration
to filter and some tags to filter and some tags

View File

@ -21,6 +21,8 @@ type Prometheus struct {
// Bearer Token authorization file path // Bearer Token authorization file path
BearerToken string `toml:"bearer_token"` BearerToken string `toml:"bearer_token"`
ResponseTimeout internal.Duration `toml:"response_timeout"`
// Path to CA file // Path to CA file
SSLCA string `toml:"ssl_ca"` SSLCA string `toml:"ssl_ca"`
// Path to host cert file // Path to host cert file
@ -38,6 +40,9 @@ var sampleConfig = `
## Use bearer token for authorization ## Use bearer token for authorization
# bearer_token = /path/to/bearer/token # bearer_token = /path/to/bearer/token
## Specify timeout duration for slower prometheus clients (default is 3s)
# response_timeout = "3s"
## Optional SSL Config ## Optional SSL Config
# ssl_ca = /path/to/cafile # ssl_ca = /path/to/cafile
# ssl_cert = /path/to/certfile # ssl_cert = /path/to/certfile
@ -105,7 +110,7 @@ func (p *Prometheus) gatherURL(url string, acc telegraf.Accumulator) error {
}).Dial, }).Dial,
TLSHandshakeTimeout: 5 * time.Second, TLSHandshakeTimeout: 5 * time.Second,
TLSClientConfig: tlsCfg, TLSClientConfig: tlsCfg,
ResponseHeaderTimeout: time.Duration(3 * time.Second), ResponseHeaderTimeout: p.ResponseTimeout.Duration,
DisableKeepAlives: true, DisableKeepAlives: true,
} }
@ -148,6 +153,6 @@ func (p *Prometheus) gatherURL(url string, acc telegraf.Accumulator) error {
func init() { func init() {
inputs.Add("prometheus", func() telegraf.Input { inputs.Add("prometheus", func() telegraf.Input {
return &Prometheus{} return &Prometheus{ResponseTimeout: "3s"}
}) })
} }