Skip to content

Commit 6de105e

Browse files
committed
feat: disable labels and annotations metrics when metric-annotations-allowlist and metric-labels-allowlist are not provided
1 parent a9bdda0 commit 6de105e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+169
-94
lines changed

internal/store/certificatesigningrequest.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ func csrMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat
4949
basemetrics.ALPHA,
5050
"",
5151
wrapCSRFunc(func(j *certv1.CertificateSigningRequest) *metric.Family {
52+
if len(allowAnnotationsList) == 0 {
53+
return &metric.Family{}
54+
}
5255
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", j.Annotations, allowAnnotationsList)
5356
return &metric.Family{
5457
Metrics: []*metric.Metric{
@@ -68,6 +71,9 @@ func csrMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat
6871
basemetrics.STABLE,
6972
"",
7073
wrapCSRFunc(func(j *certv1.CertificateSigningRequest) *metric.Family {
74+
if len(allowLabelsList) == 0 {
75+
return &metric.Family{}
76+
}
7177
labelKeys, labelValues := createPrometheusLabelKeysValues("label", j.Labels, allowLabelsList)
7278
return &metric.Family{
7379
Metrics: []*metric.Metric{

internal/store/certificatesigningrequest_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ func TestCsrStore(t *testing.T) {
5757
kube_certificatesigningrequest_created{certificatesigningrequest="certificate-test",signer_name="signer"} 1.5e+09
5858
kube_certificatesigningrequest_condition{certificatesigningrequest="certificate-test",signer_name="signer",condition="approved"} 0
5959
kube_certificatesigningrequest_condition{certificatesigningrequest="certificate-test",signer_name="signer",condition="denied"} 0
60-
kube_certificatesigningrequest_labels{certificatesigningrequest="certificate-test",signer_name="signer"} 1
6160
kube_certificatesigningrequest_cert_length{certificatesigningrequest="certificate-test",signer_name="signer"} 0
6261
`,
6362
MetricNames: []string{"kube_certificatesigningrequest_created", "kube_certificatesigningrequest_condition", "kube_certificatesigningrequest_labels", "kube_certificatesigningrequest_cert_length"},
@@ -87,7 +86,6 @@ func TestCsrStore(t *testing.T) {
8786
kube_certificatesigningrequest_created{certificatesigningrequest="certificate-test",signer_name="signer"} 1.5e+09
8887
kube_certificatesigningrequest_condition{certificatesigningrequest="certificate-test",signer_name="signer",condition="approved"} 0
8988
kube_certificatesigningrequest_condition{certificatesigningrequest="certificate-test",signer_name="signer",condition="denied"} 1
90-
kube_certificatesigningrequest_labels{certificatesigningrequest="certificate-test",signer_name="signer"} 1
9189
kube_certificatesigningrequest_cert_length{certificatesigningrequest="certificate-test",signer_name="signer"} 0
9290
`,
9391
MetricNames: []string{"kube_certificatesigningrequest_created", "kube_certificatesigningrequest_condition", "kube_certificatesigningrequest_labels", "kube_certificatesigningrequest_cert_length"},
@@ -117,7 +115,6 @@ func TestCsrStore(t *testing.T) {
117115
kube_certificatesigningrequest_created{certificatesigningrequest="certificate-test",signer_name="signer"} 1.5e+09
118116
kube_certificatesigningrequest_condition{certificatesigningrequest="certificate-test",signer_name="signer",condition="approved"} 1
119117
kube_certificatesigningrequest_condition{certificatesigningrequest="certificate-test",signer_name="signer",condition="denied"} 0
120-
kube_certificatesigningrequest_labels{certificatesigningrequest="certificate-test",signer_name="signer"} 1
121118
kube_certificatesigningrequest_cert_length{certificatesigningrequest="certificate-test",signer_name="signer"} 0
122119
`,
123120
MetricNames: []string{"kube_certificatesigningrequest_created", "kube_certificatesigningrequest_condition", "kube_certificatesigningrequest_labels", "kube_certificatesigningrequest_cert_length"},
@@ -148,7 +145,6 @@ func TestCsrStore(t *testing.T) {
148145
kube_certificatesigningrequest_created{certificatesigningrequest="certificate-test",signer_name="signer"} 1.5e+09
149146
kube_certificatesigningrequest_condition{certificatesigningrequest="certificate-test",signer_name="signer",condition="approved"} 1
150147
kube_certificatesigningrequest_condition{certificatesigningrequest="certificate-test",signer_name="signer",condition="denied"} 0
151-
kube_certificatesigningrequest_labels{certificatesigningrequest="certificate-test",signer_name="signer"} 1
152148
kube_certificatesigningrequest_cert_length{certificatesigningrequest="certificate-test",signer_name="signer"} 13
153149
`,
154150
MetricNames: []string{"kube_certificatesigningrequest_created", "kube_certificatesigningrequest_condition", "kube_certificatesigningrequest_labels", "kube_certificatesigningrequest_cert_length"},
@@ -181,7 +177,6 @@ func TestCsrStore(t *testing.T) {
181177
kube_certificatesigningrequest_created{certificatesigningrequest="certificate-test",signer_name="signer"} 1.5e+09
182178
kube_certificatesigningrequest_condition{certificatesigningrequest="certificate-test",signer_name="signer",condition="approved"} 1
183179
kube_certificatesigningrequest_condition{certificatesigningrequest="certificate-test",signer_name="signer",condition="denied"} 1
184-
kube_certificatesigningrequest_labels{certificatesigningrequest="certificate-test",signer_name="signer"} 1
185180
kube_certificatesigningrequest_cert_length{certificatesigningrequest="certificate-test",signer_name="signer"} 0
186181
`,
187182
MetricNames: []string{"kube_certificatesigningrequest_created", "kube_certificatesigningrequest_condition", "kube_certificatesigningrequest_labels", "kube_certificatesigningrequest_cert_length"},
@@ -220,7 +215,6 @@ func TestCsrStore(t *testing.T) {
220215
kube_certificatesigningrequest_created{certificatesigningrequest="certificate-test",signer_name="signer"} 1.5e+09
221216
kube_certificatesigningrequest_condition{certificatesigningrequest="certificate-test",signer_name="signer",condition="approved"} 2
222217
kube_certificatesigningrequest_condition{certificatesigningrequest="certificate-test",signer_name="signer",condition="denied"} 2
223-
kube_certificatesigningrequest_labels{certificatesigningrequest="certificate-test",signer_name="signer"} 1
224218
kube_certificatesigningrequest_cert_length{certificatesigningrequest="certificate-test",signer_name="signer"} 0
225219
`,
226220
MetricNames: []string{"kube_certificatesigningrequest_created", "kube_certificatesigningrequest_condition", "kube_certificatesigningrequest_labels", "kube_certificatesigningrequest_cert_length"},

internal/store/clusterrole.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ func clusterRoleMetricFamilies(allowAnnotationsList, allowLabelsList []string) [
4848
basemetrics.ALPHA,
4949
"",
5050
wrapClusterRoleFunc(func(r *rbacv1.ClusterRole) *metric.Family {
51+
if len(allowAnnotationsList) == 0 {
52+
return &metric.Family{}
53+
}
5154
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", r.Annotations, allowAnnotationsList)
5255
return &metric.Family{
5356
Metrics: []*metric.Metric{
@@ -67,6 +70,9 @@ func clusterRoleMetricFamilies(allowAnnotationsList, allowLabelsList []string) [
6770
basemetrics.ALPHA,
6871
"",
6972
wrapClusterRoleFunc(func(r *rbacv1.ClusterRole) *metric.Family {
73+
if len(allowLabelsList) == 0 {
74+
return &metric.Family{}
75+
}
7076
labelKeys, labelValues := createPrometheusLabelKeysValues("label", r.Labels, allowLabelsList)
7177
return &metric.Family{
7278
Metrics: []*metric.Metric{

internal/store/clusterrolebinding.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ func clusterRoleBindingMetricFamilies(allowAnnotationsList, allowLabelsList []st
4848
basemetrics.ALPHA,
4949
"",
5050
wrapClusterRoleBindingFunc(func(r *rbacv1.ClusterRoleBinding) *metric.Family {
51+
if len(allowAnnotationsList) == 0 {
52+
return &metric.Family{}
53+
}
5154
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", r.Annotations, allowAnnotationsList)
5255
return &metric.Family{
5356
Metrics: []*metric.Metric{
@@ -67,6 +70,9 @@ func clusterRoleBindingMetricFamilies(allowAnnotationsList, allowLabelsList []st
6770
basemetrics.ALPHA,
6871
"",
6972
wrapClusterRoleBindingFunc(func(r *rbacv1.ClusterRoleBinding) *metric.Family {
73+
if len(allowLabelsList) == 0 {
74+
return &metric.Family{}
75+
}
7076
labelKeys, labelValues := createPrometheusLabelKeysValues("label", r.Labels, allowLabelsList)
7177
return &metric.Family{
7278
Metrics: []*metric.Metric{

internal/store/configmap.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ func configMapMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g
4444
basemetrics.ALPHA,
4545
"",
4646
wrapConfigMapFunc(func(c *v1.ConfigMap) *metric.Family {
47+
if len(allowAnnotationsList) == 0 {
48+
return &metric.Family{}
49+
}
4750
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", c.Annotations, allowAnnotationsList)
4851
return &metric.Family{
4952
Metrics: []*metric.Metric{
@@ -63,6 +66,9 @@ func configMapMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g
6366
basemetrics.STABLE,
6467
"",
6568
wrapConfigMapFunc(func(c *v1.ConfigMap) *metric.Family {
69+
if len(allowLabelsList) == 0 {
70+
return &metric.Family{}
71+
}
6672
labelKeys, labelValues := createPrometheusLabelKeysValues("label", c.Labels, allowLabelsList)
6773
return &metric.Family{
6874
Metrics: []*metric.Metric{

internal/store/cronjob.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
5252
basemetrics.ALPHA,
5353
"",
5454
wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family {
55+
if len(allowAnnotationsList) == 0 {
56+
return &metric.Family{}
57+
}
5558
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", j.Annotations, allowAnnotationsList)
5659
return &metric.Family{
5760
Metrics: []*metric.Metric{
@@ -71,6 +74,9 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
7174
basemetrics.STABLE,
7275
"",
7376
wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family {
77+
if len(allowLabelsList) == 0 {
78+
return &metric.Family{}
79+
}
7480
labelKeys, labelValues := createPrometheusLabelKeysValues("label", j.Labels, allowLabelsList)
7581
return &metric.Family{
7682
Metrics: []*metric.Metric{

internal/store/cronjob_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ func TestCronJobStore(t *testing.T) {
161161
# TYPE kube_cronjob_status_last_schedule_time gauge
162162
kube_cronjob_info{concurrency_policy="Forbid",cronjob="ActiveRunningCronJob1",namespace="ns1",schedule="0 */6 * * *"} 1
163163
kube_cronjob_annotations{annotation_app_k8s_io_owner="@foo",cronjob="ActiveRunningCronJob1",namespace="ns1"} 1
164-
kube_cronjob_labels{cronjob="ActiveRunningCronJob1",namespace="ns1"} 1
165164
kube_cronjob_spec_failed_job_history_limit{cronjob="ActiveRunningCronJob1",namespace="ns1"} 1
166165
kube_cronjob_spec_starting_deadline_seconds{cronjob="ActiveRunningCronJob1",namespace="ns1"} 300
167166
kube_cronjob_spec_successful_job_history_limit{cronjob="ActiveRunningCronJob1",namespace="ns1"} 3
@@ -235,7 +234,6 @@ func TestCronJobStore(t *testing.T) {
235234
# TYPE kube_cronjob_status_last_schedule_time gauge
236235
# TYPE kube_cronjob_status_last_successful_time gauge
237236
kube_cronjob_info{concurrency_policy="Forbid",cronjob="SuspendedCronJob1",namespace="ns1",schedule="0 */3 * * *"} 1
238-
kube_cronjob_labels{cronjob="SuspendedCronJob1",namespace="ns1"} 1
239237
kube_cronjob_spec_failed_job_history_limit{cronjob="SuspendedCronJob1",namespace="ns1"} 1
240238
kube_cronjob_spec_starting_deadline_seconds{cronjob="SuspendedCronJob1",namespace="ns1"} 300
241239
kube_cronjob_spec_successful_job_history_limit{cronjob="SuspendedCronJob1",namespace="ns1"} 3
@@ -295,7 +293,6 @@ func TestCronJobStore(t *testing.T) {
295293
# TYPE kube_cronjob_status_last_schedule_time gauge
296294
# TYPE kube_cronjob_status_last_successful_time gauge
297295
kube_cronjob_info{concurrency_policy="Forbid",cronjob="SuspendedCronJob1",namespace="ns1",schedule="0 */3 * * *"} 1
298-
kube_cronjob_labels{cronjob="SuspendedCronJob1",namespace="ns1"} 1
299296
kube_cronjob_spec_failed_job_history_limit{cronjob="SuspendedCronJob1",namespace="ns1"} 1
300297
kube_cronjob_spec_starting_deadline_seconds{cronjob="SuspendedCronJob1",namespace="ns1"} 300
301298
kube_cronjob_spec_successful_job_history_limit{cronjob="SuspendedCronJob1",namespace="ns1"} 3
@@ -364,7 +361,6 @@ func TestCronJobStore(t *testing.T) {
364361
kube_cronjob_spec_suspend{cronjob="ActiveCronJob1NoLastScheduled",namespace="ns1"} 0
365362
kube_cronjob_info{concurrency_policy="Forbid",cronjob="ActiveCronJob1NoLastScheduled",namespace="ns1",schedule="25 * * * *"} 1
366363
kube_cronjob_created{cronjob="ActiveCronJob1NoLastScheduled",namespace="ns1"} 1.520766296e+09
367-
kube_cronjob_labels{cronjob="ActiveCronJob1NoLastScheduled",namespace="ns1"} 1
368364
` +
369365
fmt.Sprintf("kube_cronjob_next_schedule_time{cronjob=\"ActiveCronJob1NoLastScheduled\",namespace=\"ns1\"} %ve+09\n",
370366
float64(ActiveCronJob1NoLastScheduledNextScheduleTime.Unix())/math.Pow10(9)),

internal/store/daemonset.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ func daemonSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g
230230
basemetrics.ALPHA,
231231
"",
232232
wrapDaemonSetFunc(func(d *v1.DaemonSet) *metric.Family {
233+
if len(allowAnnotationsList) == 0 {
234+
return &metric.Family{}
235+
}
233236
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", d.Annotations, allowAnnotationsList)
234237
return &metric.Family{
235238
Metrics: []*metric.Metric{
@@ -249,6 +252,9 @@ func daemonSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g
249252
basemetrics.STABLE,
250253
"",
251254
wrapDaemonSetFunc(func(d *v1.DaemonSet) *metric.Family {
255+
if len(allowLabelsList) == 0 {
256+
return &metric.Family{}
257+
}
252258
labelKeys, labelValues := createPrometheusLabelKeysValues("label", d.Labels, allowLabelsList)
253259
return &metric.Family{
254260
Metrics: []*metric.Metric{

internal/store/daemonset_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ func TestDaemonSetStore(t *testing.T) {
8686
kube_daemonset_status_observed_generation{daemonset="ds1",namespace="ns1"} 2
8787
kube_daemonset_status_updated_number_scheduled{daemonset="ds1",namespace="ns1"} 0
8888
kube_daemonset_annotations{annotation_app_k8s_io_owner="@foo",daemonset="ds1",namespace="ns1"} 1
89-
kube_daemonset_labels{daemonset="ds1",namespace="ns1"} 1
9089
`,
9190
MetricNames: []string{
9291
"kube_daemonset_annotations",
@@ -149,7 +148,6 @@ func TestDaemonSetStore(t *testing.T) {
149148
kube_daemonset_status_number_ready{daemonset="ds2",namespace="ns2"} 0
150149
kube_daemonset_status_number_unavailable{daemonset="ds2",namespace="ns2"} 0
151150
kube_daemonset_status_updated_number_scheduled{daemonset="ds2",namespace="ns2"} 0
152-
kube_daemonset_labels{daemonset="ds2",namespace="ns2"} 1
153151
kube_daemonset_created{namespace="ns2",daemonset="ds2"} 1.5e+09
154152
`,
155153
MetricNames: []string{
@@ -216,7 +214,6 @@ func TestDaemonSetStore(t *testing.T) {
216214
kube_daemonset_status_number_ready{daemonset="ds3",namespace="ns3"} 5
217215
kube_daemonset_status_number_unavailable{daemonset="ds3",namespace="ns3"} 5
218216
kube_daemonset_status_updated_number_scheduled{daemonset="ds3",namespace="ns3"} 5
219-
kube_daemonset_labels{daemonset="ds3",namespace="ns3"} 1
220217
`,
221218
MetricNames: []string{
222219
"kube_daemonset_created",

internal/store/deployment.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
290290
basemetrics.ALPHA,
291291
"",
292292
wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family {
293+
if len(allowAnnotationsList) == 0 {
294+
return &metric.Family{}
295+
}
293296
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", d.Annotations, allowAnnotationsList)
294297
return &metric.Family{
295298
Metrics: []*metric.Metric{
@@ -309,6 +312,9 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
309312
basemetrics.STABLE,
310313
"",
311314
wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family {
315+
if len(allowLabelsList) == 0 {
316+
return &metric.Family{}
317+
}
312318
labelKeys, labelValues := createPrometheusLabelKeysValues("label", d.Labels, allowLabelsList)
313319
return &metric.Family{
314320
Metrics: []*metric.Metric{

internal/store/deployment_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ func TestDeploymentStore(t *testing.T) {
115115
Want: metadata + `
116116
kube_deployment_annotations{annotation_company_io_team="my-brilliant-team",deployment="depl1",namespace="ns1"} 1
117117
kube_deployment_created{deployment="depl1",namespace="ns1"} 1.5e+09
118-
kube_deployment_labels{deployment="depl1",namespace="ns1"} 1
119118
kube_deployment_metadata_generation{deployment="depl1",namespace="ns1"} 21
120119
kube_deployment_spec_paused{deployment="depl1",namespace="ns1"} 0
121120
kube_deployment_spec_replicas{deployment="depl1",namespace="ns1"} 200
@@ -170,8 +169,6 @@ func TestDeploymentStore(t *testing.T) {
170169
},
171170
},
172171
Want: metadata + `
173-
kube_deployment_annotations{deployment="depl2",namespace="ns2"} 1
174-
kube_deployment_labels{deployment="depl2",namespace="ns2"} 1
175172
kube_deployment_metadata_generation{deployment="depl2",namespace="ns2"} 14
176173
kube_deployment_spec_paused{deployment="depl2",namespace="ns2"} 1
177174
kube_deployment_spec_replicas{deployment="depl2",namespace="ns2"} 5

internal/store/endpoint.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []ge
8686
basemetrics.ALPHA,
8787
"",
8888
wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family {
89+
if len(allowAnnotationsList) == 0 {
90+
return &metric.Family{}
91+
}
8992
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", e.Annotations, allowAnnotationsList)
9093
return &metric.Family{
9194
Metrics: []*metric.Metric{
@@ -105,6 +108,9 @@ func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []ge
105108
basemetrics.STABLE,
106109
"",
107110
wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family {
111+
if len(allowLabelsList) == 0 {
112+
return &metric.Family{}
113+
}
108114
labelKeys, labelValues := createPrometheusLabelKeysValues("label", e.Labels, allowLabelsList)
109115
return &metric.Family{
110116
Metrics: []*metric.Metric{

internal/store/endpoint_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,10 @@ func TestEndpointStore(t *testing.T) {
8989
},
9090
},
9191
Want: metadata + `
92-
kube_endpoint_annotations{endpoint="test-endpoint",namespace="default"} 1
9392
kube_endpoint_address_available{endpoint="test-endpoint",namespace="default"} 6
9493
kube_endpoint_address_not_ready{endpoint="test-endpoint",namespace="default"} 6
9594
kube_endpoint_created{endpoint="test-endpoint",namespace="default"} 1.5e+09
9695
kube_endpoint_info{endpoint="test-endpoint",namespace="default"} 1
97-
kube_endpoint_labels{endpoint="test-endpoint",namespace="default"} 1
9896
kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="http",port_protocol="TCP",port_number="8080"} 1
9997
kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="app",port_protocol="TCP",port_number="8081"} 1
10098
kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="https",port_protocol="TCP",port_number="8443"} 1
@@ -134,12 +132,10 @@ func TestEndpointStore(t *testing.T) {
134132
},
135133
},
136134
Want: metadata + `
137-
kube_endpoint_annotations{endpoint="single-port-endpoint",namespace="default"} 1
138135
kube_endpoint_address_available{endpoint="single-port-endpoint",namespace="default"} 2
139136
kube_endpoint_address_not_ready{endpoint="single-port-endpoint",namespace="default"} 1
140137
kube_endpoint_created{endpoint="single-port-endpoint",namespace="default"} 1.5e+09
141138
kube_endpoint_info{endpoint="single-port-endpoint",namespace="default"} 1
142-
kube_endpoint_labels{endpoint="single-port-endpoint",namespace="default"} 1
143139
kube_endpoint_ports{endpoint="single-port-endpoint",namespace="default",port_name="",port_number="8080",port_protocol="TCP"} 1
144140
kube_endpoint_address{endpoint="single-port-endpoint",namespace="default",ip="127.0.0.1",ready="true"} 1
145141
kube_endpoint_address{endpoint="single-port-endpoint",namespace="default",ip="10.0.0.1",ready="true"} 1

internal/store/endpointslice.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ func endpointSliceMetricFamilies(allowAnnotationsList, allowLabelsList []string)
174174
basemetrics.ALPHA,
175175
"",
176176
wrapEndpointSliceFunc(func(s *discoveryv1.EndpointSlice) *metric.Family {
177+
if len(allowAnnotationsList) == 0 {
178+
return &metric.Family{}
179+
}
177180
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", s.Annotations, allowAnnotationsList)
178181
return &metric.Family{
179182
Metrics: []*metric.Metric{
@@ -193,6 +196,9 @@ func endpointSliceMetricFamilies(allowAnnotationsList, allowLabelsList []string)
193196
basemetrics.ALPHA,
194197
"",
195198
wrapEndpointSliceFunc(func(s *discoveryv1.EndpointSlice) *metric.Family {
199+
if len(allowLabelsList) == 0 {
200+
return &metric.Family{}
201+
}
196202
labelKeys, labelValues := createPrometheusLabelKeysValues("label", s.Labels, allowLabelsList)
197203
return &metric.Family{
198204
Metrics: []*metric.Metric{

0 commit comments

Comments
 (0)