diff --git a/main_test.go b/main_test.go index 81f920f0a1..719bd7ad0d 100644 --- a/main_test.go +++ b/main_test.go @@ -138,7 +138,12 @@ func TestFullScrapeCycle(t *testing.T) { t.Fatal(err) } builder.WithAllowDenyList(l) - builder.WithAllowLabels(map[string][]string{}) + builder.WithAllowLabels(map[string][]string{ + "kube_pod_labels": { + "namespace", + "pod", + }, + }) handler := metricshandler.New(&options.Options{}, kubeClient, builder, false) handler.ConfigureSharding(ctx, 0, 1) diff --git a/pkg/metric_generator/generator.go b/pkg/metric_generator/generator.go index 248cb36aa8..9db280c81e 100644 --- a/pkg/metric_generator/generator.go +++ b/pkg/metric_generator/generator.go @@ -135,7 +135,7 @@ func FilterMetricFamiliesLabels(allowLabels allowLabels, families []FamilyGenera metricFamily := familyGenerator.GenerateFunc(obj) for _, m := range metricFamily.Metrics { - m.LabelKeys, m.LabelValues = allowLabels.Allowed(f.Name, m.LabelKeys, m.LabelValues) + m.LabelKeys, m.LabelValues = allowLabels.Allowed(familyGenerator.Name, m.LabelKeys, m.LabelValues) } return metricFamily }