Skip to content

Commit

Permalink
pkg/endpoint: reduce cardinality of prometheus labels
Browse files Browse the repository at this point in the history
[ upstream commit ec16cab ]

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>
Signed-off-by: Paul Chaignon <paul@cilium.io>
  • Loading branch information
aanm authored and joestringer committed Oct 22, 2020
1 parent 9494169 commit fda8422
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/endpoint/endpoint.go
Expand Up @@ -1531,7 +1531,8 @@ type MetadataResolverCB func(ns, podName string) (identityLabels labels.Labels,
// 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 @@ -1547,7 +1548,7 @@ func (e *Endpoint) RunMetadataResolver(resolveMetadata MetadataResolverCB) {
ns, podName := e.GetK8sNamespace(), e.GetK8sPodName()
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.UpdateVisibilityPolicy(func(_, _ string) (proxyVisibility string, err error) {
Expand Down

0 comments on commit fda8422

Please sign in to comment.