File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -20,10 +20,12 @@ MULTI_ARCH_IMG = $(IMAGE)-$(ARCH)
2020USER ?= $(shell id -u -n)
2121HOST ?= $(shell hostname)
2222MARKDOWNLINT_CLI2_VERSION = 0.18.1
23+ CLIENT_GO_VERSION = $(shell go list -m -f '{{.Version}}' k8s.io/client-go)
24+ KSM_MODULE = $(shell go list -m)
2325
2426DOCKER_CLI ?= docker
2527PROMTOOL_CLI ?= promtool
26- GOMPLATE_CLI ?= go tool github.com/hairyhenderson/gomplate/v4/cmd/gomplate
28+ GOMPLATE_CLI ?= go tool github.com/hairyhenderson/gomplate/v4/cmd/gomplate
2729GOJSONTOYAML_CLI ?= go tool github.com/brancz/gojsontoyaml
2830EMBEDMD_CLI ?= go tool github.com/campoy/embedmd
2931JSONNET_CLI ?= go tool github.com/google/go-jsonnet/cmd/jsonnet
@@ -69,7 +71,7 @@ doccheck: generate validate-template
6971 @echo OK
7072
7173build-local :
72- GOOS=$(OS ) GOARCH=$(ARCH ) CGO_ENABLED=0 go build -ldflags " -s -w -X ${PKG} /version.Version=${TAG} -X ${PKG} /version.Revision=${GIT_COMMIT} -X ${PKG} /version.Branch=${BRANCH} -X ${PKG} /version.BuildUser=${USER} @${HOST} -X ${PKG} /version.BuildDate=${BUILD_DATE} " -o kube-state-metrics
74+ GOOS=$(OS ) GOARCH=$(ARCH ) CGO_ENABLED=0 go build -ldflags " -s -w -X ${PKG} /version.Version=${TAG} -X ${PKG} /version.Revision=${GIT_COMMIT} -X ${PKG} /version.Branch=${BRANCH} -X ${PKG} /version.BuildUser=${USER} @${HOST} -X ${PKG} /version.BuildDate=${BUILD_DATE} -X ${PKG} /version.BuildDate= ${BUILD_DATE} -X ${KSM_MODULE} /pkg/app.ClientGoVersion= ${CLIENT_GO_VERSION} " -o kube-state-metrics
7375
7476build : kube-state-metrics
7577
Original file line number Diff line number Diff line change @@ -63,6 +63,10 @@ import (
6363 "k8s.io/kube-state-metrics/v2/pkg/util/proc"
6464)
6565
66+ // ClientGoVersion is the version for the client-go library used by KSM. This
67+ // value is set at build time using go build flags.
68+ var ClientGoVersion = "unknown"
69+
6670const (
6771 metricsPath = "/metrics"
6872 healthzPath = "/healthz"
@@ -86,6 +90,16 @@ func RunKubeStateMetricsWrapper(ctx context.Context, opts *options.Options) erro
8690func RunKubeStateMetrics (ctx context.Context , opts * options.Options ) error {
8791 ksmMetricsRegistry := prometheus .NewRegistry ()
8892 ksmMetricsRegistry .MustRegister (versionCollector .NewCollector ("kube_state_metrics" ))
93+
94+ clientGoVersion := promauto .With (ksmMetricsRegistry ).NewGaugeVec (
95+ prometheus.GaugeOpts {
96+ Name : "kube_state_metrics_client_go_info" ,
97+ Help : "An info metric for the client-go version used by kube-state-metrics" ,
98+ },
99+ []string {"version" },
100+ )
101+ clientGoVersion .WithLabelValues (ClientGoVersion ).Set (1 )
102+
89103 durationVec := promauto .With (ksmMetricsRegistry ).NewHistogramVec (
90104 prometheus.HistogramOpts {
91105 Name : "http_request_duration_seconds" ,
You can’t perform that action at this time.
0 commit comments