Update http header User-Agent in k8s and swarm discovery. (#7614)

* discovery: update k8s and swarm user agent.

Signed-off-by: johncming <johncming@yahoo.com>
This commit is contained in:
johncming 2020-07-31 06:18:38 +08:00 committed by GitHub
parent f482c7bdd7
commit 3c5ff27959
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -15,6 +15,7 @@ package kubernetes
import (
"context"
"fmt"
"reflect"
"strings"
"sync"
@ -36,6 +37,7 @@ import (
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
"github.com/prometheus/common/version"
"github.com/prometheus/prometheus/discovery/targetgroup"
)
@ -49,6 +51,8 @@ const (
)
var (
// Http header
userAgent = fmt.Sprintf("Prometheus/%s", version.Version)
// Custom events metric
eventCount = prometheus.NewCounterVec(
prometheus.CounterOpts{
@ -262,7 +266,7 @@ func New(l log.Logger, conf *SDConfig) (*Discovery, error) {
}
}
kcfg.UserAgent = "Prometheus/discovery"
kcfg.UserAgent = userAgent
c, err := kubernetes.NewForConfig(kcfg)
if err != nil {