mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/promscrape: add -promscrape.disableKeepAlive
command-line flag for disabling http keep-alive connections when scraping targets
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/580
This commit is contained in:
parent
aa26b94f33
commit
0f754bea49
1 changed files with 5 additions and 0 deletions
|
@ -16,6 +16,8 @@ var (
|
||||||
"Bigger responses are rejected")
|
"Bigger responses are rejected")
|
||||||
disableCompression = flag.Bool("promscrape.disableCompression", false, "Whether to disable sending 'Accept-Encoding: gzip' request headers to scrape targets. "+
|
disableCompression = flag.Bool("promscrape.disableCompression", false, "Whether to disable sending 'Accept-Encoding: gzip' request headers to scrape targets. "+
|
||||||
"This may reduce CPU usage on scrape targets at the cost of higher network bandwidth utilization")
|
"This may reduce CPU usage on scrape targets at the cost of higher network bandwidth utilization")
|
||||||
|
disableKeepAlive = flag.Bool("promscrape.disableKeepAlive", false, "Whether to disable HTTP keep-alive connections when scraping targets. This may be useful when targets "+
|
||||||
|
"has no support for HTTP keep-alive connection. Note that disabling HTTP keep-alive may increase load on both vmagent and scrape targets")
|
||||||
)
|
)
|
||||||
|
|
||||||
type client struct {
|
type client struct {
|
||||||
|
@ -73,6 +75,9 @@ func (c *client) ReadData(dst []byte) ([]byte, error) {
|
||||||
if !*disableCompression {
|
if !*disableCompression {
|
||||||
req.Header.Set("Accept-Encoding", "gzip")
|
req.Header.Set("Accept-Encoding", "gzip")
|
||||||
}
|
}
|
||||||
|
if *disableKeepAlive {
|
||||||
|
req.SetConnectionClose()
|
||||||
|
}
|
||||||
if c.authHeader != "" {
|
if c.authHeader != "" {
|
||||||
req.Header.Set("Authorization", c.authHeader)
|
req.Header.Set("Authorization", c.authHeader)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue