app/vmagent: follow-up after 6788704152

https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4884
Signed-off-by: hagen1778 <roman@victoriametrics.com>
(cherry picked from commit 4ebe8bb1d5)
This commit is contained in:
hagen1778 2023-08-24 11:36:42 +02:00
parent 1242460fa6
commit b18e9b5bb0
No known key found for this signature in database
GPG key ID: 3BF75F3741CA9640
2 changed files with 8 additions and 4 deletions

View file

@ -31,6 +31,8 @@ The following `tip` changes can be tested by building VictoriaMetrics components
* FEATURE: [vmui](https://docs.victoriametrics.com/#vmui): make the warning message more noticeable for text fields. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4848).
* FEATURE: [vmui](https://docs.victoriametrics.com/#vmui): add button for auto-formatting PromQL/MetricsQL queries. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4681). Thanks to @aramattamara for the [pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4694).
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): consistently set UserAgent header to `vm_promscrape` during scraping with enabled or disabled `promscrape.streamParse`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4884) for details.
## [v1.93.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.93.1)
Released at 2023-08-23

View file

@ -79,6 +79,8 @@ func concatTwoStrings(x, y string) string {
return s
}
const scrapeUserAgent = "vm_promscrape"
func newClient(ctx context.Context, sw *ScrapeWork) *client {
var u fasthttp.URI
u.Update(sw.ScrapeURL)
@ -120,8 +122,9 @@ func newClient(ctx context.Context, sw *ScrapeWork) *client {
logger.Fatalf("cannot create dial func: %s", err)
}
hc := &fasthttp.HostClient{
Addr: dialAddr,
Name: "vm_promscrape",
Addr: dialAddr,
// Name used in User-Agent request header
Name: scrapeUserAgent,
Dial: dialFunc,
IsTLS: isTLS,
TLSConfig: tlsCfg,
@ -201,8 +204,7 @@ func (c *client) GetStreamReader() (*streamReader, error) {
// Set X-Prometheus-Scrape-Timeout-Seconds like Prometheus does, since it is used by some exporters such as PushProx.
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1179#issuecomment-813117162
req.Header.Set("X-Prometheus-Scrape-Timeout-Seconds", c.scrapeTimeoutSecondsStr)
// Set same useragent as fasthttp.HostClient at c.hc uses for scraping
req.Header.Set("User-Agent", "vm_promscrape")
req.Header.Set("User-Agent", scrapeUserAgent)
c.setHeaders(req)
c.setProxyHeaders(req)
scrapeRequests.Inc()