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)
20
20
USER ?= $(shell id -u -n)
21
21
HOST ?= $(shell hostname)
22
22
MARKDOWNLINT_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)
23
25
24
26
DOCKER_CLI ?= docker
25
27
PROMTOOL_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
27
29
GOJSONTOYAML_CLI ?= go tool github.com/brancz/gojsontoyaml
28
30
EMBEDMD_CLI ?= go tool github.com/campoy/embedmd
29
31
JSONNET_CLI ?= go tool github.com/google/go-jsonnet/cmd/jsonnet
@@ -69,7 +71,7 @@ doccheck: generate validate-template
69
71
@echo OK
70
72
71
73
build-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
73
75
74
76
build : kube-state-metrics
75
77
Original file line number Diff line number Diff line change @@ -63,6 +63,10 @@ import (
63
63
"k8s.io/kube-state-metrics/v2/pkg/util/proc"
64
64
)
65
65
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
+
66
70
const (
67
71
metricsPath = "/metrics"
68
72
healthzPath = "/healthz"
@@ -86,6 +90,16 @@ func RunKubeStateMetricsWrapper(ctx context.Context, opts *options.Options) erro
86
90
func RunKubeStateMetrics (ctx context.Context , opts * options.Options ) error {
87
91
ksmMetricsRegistry := prometheus .NewRegistry ()
88
92
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
+
89
103
durationVec := promauto .With (ksmMetricsRegistry ).NewHistogramVec (
90
104
prometheus.HistogramOpts {
91
105
Name : "http_request_duration_seconds" ,
You can’t perform that action at this time.
0 commit comments