Setting User-Agent header
@@ -24,6 +24,7 @@ import (
"github.com/prometheus/common/expfmt"
"github.com/prometheus/common/log"
"github.com/prometheus/common/model"
+ "github.com/prometheus/common/version"
"golang.org/x/net/context"
"golang.org/x/net/context/ctxhttp"
@@ -286,12 +287,15 @@ type targetScraper struct {
const acceptHeader = `application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily;encoding=delimited;q=0.7,text/plain;version=0.0.4;q=0.3,*/*;q=0.1`
+var userAgentHeader = fmt.Sprintf("Prometheus/%s", version.Version)
+
func (s *targetScraper) scrape(ctx context.Context, ts time.Time) (model.Samples, error) {
req, err := http.NewRequest("GET", s.URL().String(), nil)
if err != nil {
return nil, err
}
req.Header.Add("Accept", acceptHeader)
+ req.Header.Set("User-Agent", userAgentHeader)
resp, err := ctxhttp.Do(ctx, s.client, req)
if err != nil {
