diff --git a/discovery/kubernetes/kubernetes.go b/discovery/kubernetes/kubernetes.go index 5315badd03..1e063bc715 100644 --- a/discovery/kubernetes/kubernetes.go +++ b/discovery/kubernetes/kubernetes.go @@ -238,7 +238,7 @@ func New(l log.Logger, conf *SDConfig) (*Discovery, error) { } } - kcfg.UserAgent = "prometheus/discovery" + kcfg.UserAgent = "Prometheus/discovery" c, err := kubernetes.NewForConfig(kcfg) if err != nil { diff --git a/notifier/notifier.go b/notifier/notifier.go index 8604fe28d9..3b31c8fb47 100644 --- a/notifier/notifier.go +++ b/notifier/notifier.go @@ -33,6 +33,7 @@ import ( "github.com/prometheus/client_golang/prometheus" config_util "github.com/prometheus/common/config" "github.com/prometheus/common/model" + "github.com/prometheus/common/version" "github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/discovery/targetgroup" @@ -52,6 +53,8 @@ const ( alertmanagerLabel = "alertmanager" ) +var userAgent = fmt.Sprintf("Prometheus/%s", version.Version) + // Alert is a generic representation of an alert in the Prometheus eco-system. type Alert struct { // Label value pairs for purpose of aggregation, matching, and disposition @@ -498,6 +501,7 @@ func (n *Manager) sendOne(ctx context.Context, c *http.Client, url string, b []b if err != nil { return err } + req.Header.Set("User-Agent", userAgent) req.Header.Set("Content-Type", contentTypeJSON) resp, err := n.opts.Do(ctx, c, req) if err != nil { diff --git a/storage/remote/client.go b/storage/remote/client.go index 6e1f8f0fc7..2679f42b6b 100644 --- a/storage/remote/client.go +++ b/storage/remote/client.go @@ -26,6 +26,7 @@ import ( "github.com/gogo/protobuf/proto" "github.com/golang/snappy" "github.com/prometheus/common/model" + "github.com/prometheus/common/version" config_util "github.com/prometheus/common/config" "github.com/prometheus/prometheus/prompb" @@ -33,6 +34,8 @@ import ( const maxErrMsgLen = 256 +var userAgent = fmt.Sprintf("Prometheus/%s", version.Version) + // Client allows reading and writing from/to a remote HTTP endpoint. type Client struct { index int // Used to differentiate clients in metrics. @@ -83,6 +86,7 @@ func (c *Client) Store(ctx context.Context, req *prompb.WriteRequest) error { } httpReq.Header.Add("Content-Encoding", "snappy") httpReq.Header.Set("Content-Type", "application/x-protobuf") + httpReq.Header.Set("User-Agent", userAgent) httpReq.Header.Set("X-Prometheus-Remote-Write-Version", "0.1.0") httpReq = httpReq.WithContext(ctx) @@ -138,6 +142,7 @@ func (c *Client) Read(ctx context.Context, query *prompb.Query) (*prompb.QueryRe httpReq.Header.Add("Content-Encoding", "snappy") httpReq.Header.Add("Accept-Encoding", "snappy") httpReq.Header.Set("Content-Type", "application/x-protobuf") + httpReq.Header.Set("User-Agent", userAgent) httpReq.Header.Set("X-Prometheus-Remote-Read-Version", "0.1.0") ctx, cancel := context.WithTimeout(ctx, c.timeout)