As already mentioned in this issue https://github.com/kubernetes/kubernetes/issues/79286, some metrics like "running_pod_count" and "running_container_count" uses non-standard prometheus metrics, this change converts them to be standard prometheus gauges Minor refactor in kubelet/pleg/generic.go and added some test for ruuning container and running pod metrics Fixed issues related to github CI pipeline failure * Updated bazel for new deps * Add comment for exported metrics variables,RuuningContainerCount and RunningPodCount * Specify keys explicitly in Guage metric instantation Fix go lint errors Replace "+=1" with "++", as reported by go lint Set container state as a label for the metrics "running_container_count" As per the metrics name "running_container_count" it should "ideally" be showing the number of containers in "running" state , but it was showing all the container count, irrespective of the state it is in. This commit adds a new label "container_running_state" to the metrics "running_container_count", which doesn't change the base metrics but adds the option to query the metrics with "container_state" such as "running"/"unknown/... remove unused methods reported by staticcheck Remove variables while instantiating gauge(vec) which are default set to nil Convert kubelet metrics(running_pod_count and running_container_count) to standard gauges and added label to running_container_count metrics. Currently kubelet metrics(running_pod_count and running_container_count) use non-standard prometheus collectors , this change converts them to standard prometheus gauges. Also this adds a new label(container_state) to running_container_count which does a breakdown of containers tracked by kubelet based on the containers' state(running/unknown/created/exited). Set statbility explicitly for running_pod_count and running_container_count and reformat test register metrics explicitly in test , so that they don't become no-op
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
package(default_visibility = ["//visibility:public"])
|
|
|
|
load(
|
|
"@io_bazel_rules_go//go:def.bzl",
|
|
"go_library",
|
|
"go_test",
|
|
)
|
|
|
|
go_library(
|
|
name = "go_default_library",
|
|
srcs = [
|
|
"doc.go",
|
|
"generic.go",
|
|
"pleg.go",
|
|
],
|
|
importpath = "k8s.io/kubernetes/pkg/kubelet/pleg",
|
|
deps = [
|
|
"//pkg/kubelet/container:go_default_library",
|
|
"//pkg/kubelet/metrics:go_default_library",
|
|
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
|
"//staging/src/k8s.io/apimachinery/pkg/util/clock:go_default_library",
|
|
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
|
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
|
"//staging/src/k8s.io/cri-api/pkg/apis/runtime/v1alpha2:go_default_library",
|
|
"//vendor/k8s.io/klog:go_default_library",
|
|
],
|
|
)
|
|
|
|
go_test(
|
|
name = "go_default_test",
|
|
srcs = ["generic_test.go"],
|
|
embed = [":go_default_library"],
|
|
deps = [
|
|
"//pkg/kubelet/container:go_default_library",
|
|
"//pkg/kubelet/container/testing:go_default_library",
|
|
"//pkg/kubelet/metrics:go_default_library",
|
|
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
|
"//staging/src/k8s.io/apimachinery/pkg/util/clock:go_default_library",
|
|
"//staging/src/k8s.io/apimachinery/pkg/util/diff:go_default_library",
|
|
"//vendor/github.com/prometheus/client_model/go:go_default_library",
|
|
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
|
],
|
|
)
|
|
|
|
filegroup(
|
|
name = "package-srcs",
|
|
srcs = glob(["**"]),
|
|
tags = ["automanaged"],
|
|
visibility = ["//visibility:private"],
|
|
)
|
|
|
|
filegroup(
|
|
name = "all-srcs",
|
|
srcs = [":package-srcs"],
|
|
tags = ["automanaged"],
|
|
)
|