From 52fcb27e71e4162a207640fa8724757feab6904f Mon Sep 17 00:00:00 2001 From: SuperQ Date: Mon, 19 Jun 2023 16:24:46 +0200 Subject: [PATCH] Remove name label from k8s client metrics The `name` label in the `controller_clientset_k8s_request_total` metric produce an excessive amount of cardinality as `events` metrics generate a new string for each event. Similarly, each new `replicasets` also generates a new label set. This can lead to hundreds of thousands of unique metrics over a couple weeks in a large deployment. Signed-off-by: SuperQ --- controller/metrics/client.go | 7 +------ controller/metrics/prommetrics.go | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/controller/metrics/client.go b/controller/metrics/client.go index 01367745ef..c2b8220828 100644 --- a/controller/metrics/client.go +++ b/controller/metrics/client.go @@ -23,20 +23,15 @@ func (f *K8sRequestsCountProvider) MustRegister(registerer prometheus.Registerer // IncKubernetesRequest increments the kubernetes client counter func (m *K8sRequestsCountProvider) IncKubernetesRequest(resourceInfo kubeclientmetrics.ResourceInfo) error { - name := resourceInfo.Name namespace := resourceInfo.Namespace kind := resourceInfo.Kind statusCode := strconv.Itoa(resourceInfo.StatusCode) - if resourceInfo.Verb == kubeclientmetrics.List { - name = "N/A" - } if resourceInfo.Verb == kubeclientmetrics.Unknown { namespace = "Unknown" - name = "Unknown" kind = "Unknown" } if m.k8sRequestsCount != nil { - m.k8sRequestsCount.WithLabelValues(kind, namespace, name, string(resourceInfo.Verb), statusCode).Inc() + m.k8sRequestsCount.WithLabelValues(kind, namespace, string(resourceInfo.Verb), statusCode).Inc() } return nil } diff --git a/controller/metrics/prommetrics.go b/controller/metrics/prommetrics.go index 3e55ba1ccb..c0cb3744e5 100644 --- a/controller/metrics/prommetrics.go +++ b/controller/metrics/prommetrics.go @@ -219,7 +219,7 @@ var ( Name: "k8s_request_total", Help: "Number of kubernetes requests executed during application reconciliation.", }, - []string{"kind", "namespace", "name", "verb", "status_code"}, + []string{"kind", "namespace", "verb", "status_code"}, ) )