outputs/http: add option to control idle connection timeout (#8055)
Co-authored-by: Yuri Grigorov <jurijs.grigorovs@corp.mail.ru>
This commit is contained in:
parent
33d5ba49dc
commit
c319e63a5a
|
|
@ -48,4 +48,9 @@ data formats. For data_formats that support batching, metrics are sent in batch
|
||||||
# [outputs.http.headers]
|
# [outputs.http.headers]
|
||||||
# # Should be set manually to "application/json" for json data_format
|
# # Should be set manually to "application/json" for json data_format
|
||||||
# Content-Type = "text/plain; charset=utf-8"
|
# Content-Type = "text/plain; charset=utf-8"
|
||||||
|
|
||||||
|
## Idle (keep-alive) connection timeout.
|
||||||
|
## Maximum amount of time before idle connection is closed.
|
||||||
|
## Zero means no limit.
|
||||||
|
# idle_conn_timeout = 0
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,11 @@ var sampleConfig = `
|
||||||
# [outputs.http.headers]
|
# [outputs.http.headers]
|
||||||
# # Should be set manually to "application/json" for json data_format
|
# # Should be set manually to "application/json" for json data_format
|
||||||
# Content-Type = "text/plain; charset=utf-8"
|
# Content-Type = "text/plain; charset=utf-8"
|
||||||
|
|
||||||
|
## Idle (keep-alive) connection timeout.
|
||||||
|
## Maximum amount of time before idle connection is closed.
|
||||||
|
## Zero means no limit.
|
||||||
|
# idle_conn_timeout = 0
|
||||||
`
|
`
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -84,6 +89,7 @@ type HTTP struct {
|
||||||
TokenURL string `toml:"token_url"`
|
TokenURL string `toml:"token_url"`
|
||||||
Scopes []string `toml:"scopes"`
|
Scopes []string `toml:"scopes"`
|
||||||
ContentEncoding string `toml:"content_encoding"`
|
ContentEncoding string `toml:"content_encoding"`
|
||||||
|
IdleConnTimeout internal.Duration `toml:"idle_conn_timeout"`
|
||||||
tls.ClientConfig
|
tls.ClientConfig
|
||||||
|
|
||||||
client *http.Client
|
client *http.Client
|
||||||
|
|
@ -104,6 +110,7 @@ func (h *HTTP) createClient(ctx context.Context) (*http.Client, error) {
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
TLSClientConfig: tlsCfg,
|
TLSClientConfig: tlsCfg,
|
||||||
Proxy: http.ProxyFromEnvironment,
|
Proxy: http.ProxyFromEnvironment,
|
||||||
|
IdleConnTimeout: h.IdleConnTimeout.Duration,
|
||||||
},
|
},
|
||||||
Timeout: h.Timeout.Duration,
|
Timeout: h.Timeout.Duration,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue