From 1242460fa638e72870631c4915fe69880deb0229 Mon Sep 17 00:00:00 2001 From: Zakhar Bessarab Date: Thu, 24 Aug 2023 13:31:13 +0400 Subject: [PATCH] lib/promscrape/client: make User-Agent consistent between fasthttp and native client (#4886) User agent was not set for native client which resulted in using one provided by Golang. See: https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4884 Signed-off-by: Zakhar Bessarab (cherry picked from commit 6788704152395567a2221d8ea8edeb98338e13d3) --- lib/promscrape/client.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/promscrape/client.go b/lib/promscrape/client.go index 420589dd9..06da77076 100644 --- a/lib/promscrape/client.go +++ b/lib/promscrape/client.go @@ -201,6 +201,8 @@ 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") c.setHeaders(req) c.setProxyHeaders(req) scrapeRequests.Inc()