Changed response_timeout property to use Duration instead of int
This commit is contained in:
parent
eb4c000d4f
commit
e87d95d509
|
@ -20,8 +20,8 @@ Specify a 10 second timeout for slower/over-loaded clients
|
||||||
# An array of urls to scrape metrics from.
|
# An array of urls to scrape metrics from.
|
||||||
urls = ["http://my-kube-apiserver:8080/metrics"]
|
urls = ["http://my-kube-apiserver:8080/metrics"]
|
||||||
|
|
||||||
# Specify timeout in seconds for slower prometheus clients (default is 3)
|
# Specify timeout duration for slower prometheus clients (default is 3s)
|
||||||
response_timeout = 10
|
response_timeout = 10s
|
||||||
```
|
```
|
||||||
|
|
||||||
You can use more complex configuration
|
You can use more complex configuration
|
||||||
|
|
|
@ -21,7 +21,7 @@ type Prometheus struct {
|
||||||
// Bearer Token authorization file path
|
// Bearer Token authorization file path
|
||||||
BearerToken string `toml:"bearer_token"`
|
BearerToken string `toml:"bearer_token"`
|
||||||
|
|
||||||
ResponseTimeout int `toml:"response_timeout"`
|
ResponseTimeout internal.Duration `toml:"response_timeout"`
|
||||||
|
|
||||||
// Path to CA file
|
// Path to CA file
|
||||||
SSLCA string `toml:"ssl_ca"`
|
SSLCA string `toml:"ssl_ca"`
|
||||||
|
@ -40,8 +40,8 @@ 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 in seconds for slower prometheus clients (default is 3)
|
## Specify timeout duration for slower prometheus clients (default is 3s)
|
||||||
# response_timeout = 3
|
# response_timeout = 3s
|
||||||
|
|
||||||
## Optional SSL Config
|
## Optional SSL Config
|
||||||
# ssl_ca = /path/to/cafile
|
# ssl_ca = /path/to/cafile
|
||||||
|
@ -110,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(time.Duration(p.ResponseTimeout) * time.Second),
|
ResponseHeaderTimeout: p.ResponseTimeout.Duration,
|
||||||
DisableKeepAlives: true,
|
DisableKeepAlives: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,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{ResponseTimeout: 3}
|
return &Prometheus{ResponseTimeout: "3s"}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue