Skip to content

Commit

Permalink
pkg/endpoint: reduce cardinality of prometheus labels
Browse files Browse the repository at this point in the history
If the controller that is used for label resolution fails, the
prometheus metrics will increase its cardinality since the uniquely
controller name was being used as a prometheus label. To avoid this, we
will reference these warnings with a common subsystem name,
'resolve-labels'.

Fixes: a31ab29 ("endpoint: Run labels controller under ep manager")
Signed-off-by: André Martins <andre@cilium.io>
  • Loading branch information
aanm committed Oct 22, 2020
1 parent a8e67f1 commit ec16cab
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/endpoint/endpoint.go
Expand Up @@ -1645,7 +1645,8 @@ type MetadataResolverCB func(ns, podName string) (pod *slim_corev1.Pod, _ []slim
// will handle updates (such as pkg/k8s/watchers informers).
func (e *Endpoint) RunMetadataResolver(resolveMetadata MetadataResolverCB) {
done := make(chan struct{})
controllerName := fmt.Sprintf("resolve-labels-%s", e.GetK8sNamespaceAndPodName())
const controllerPrefix = "resolve-labels"
controllerName := fmt.Sprintf("%s-%s", controllerPrefix, e.GetK8sNamespaceAndPodName())
go func() {
select {
case <-done:
Expand All @@ -1661,7 +1662,7 @@ func (e *Endpoint) RunMetadataResolver(resolveMetadata MetadataResolverCB) {
ns, podName := e.GetK8sNamespace(), e.GetK8sPodName()
pod, cp, identityLabels, info, _, err := resolveMetadata(ns, podName)
if err != nil {
e.Logger(controllerName).WithError(err).Warning("Unable to fetch kubernetes labels")
e.Logger(controllerPrefix).WithError(err).Warning("Unable to fetch kubernetes labels")
return err
}
e.SetPod(pod)
Expand Down

0 comments on commit ec16cab

Please sign in to comment.