diff --git a/packages/extra/ingress/templates/nginx-scrape.yaml b/packages/extra/ingress/templates/nginx-scrape.yaml index d04c5b651..780f5e3a9 100644 --- a/packages/extra/ingress/templates/nginx-scrape.yaml +++ b/packages/extra/ingress/templates/nginx-scrape.yaml @@ -9,6 +9,10 @@ spec: matchNames: - {{ .Release.Namespace }} podMetricsEndpoints: + # The series describe the Ingress objects served, in any namespace, not + # this controller, so the application identity the vmagent scrape class + # stamps from the controller pod would misattribute them; and with + # honorLabels an exporter-supplied identity would win over the class. - port: metrics honorLabels: true interval: 30s @@ -19,6 +23,9 @@ spec: targetLabel: node - targetLabel: tier replacement: cluster + metricRelabelConfigs: + - action: labeldrop + regex: apps_cozystack_io_application_(group|kind|name) selector: matchLabels: app.kubernetes.io/component: controller @@ -46,6 +53,9 @@ spec: targetLabel: controller - targetLabel: tier replacement: cluster + metricRelabelConfigs: + - action: labeldrop + regex: apps_cozystack_io_application_(group|kind|name) selector: matchLabels: app.kubernetes.io/component: controller diff --git a/packages/extra/ingress/tests/application_identity_test.yaml b/packages/extra/ingress/tests/application_identity_test.yaml new file mode 100644 index 000000000..e1be5ca4f --- /dev/null +++ b/packages/extra/ingress/tests/application_identity_test.yaml @@ -0,0 +1,21 @@ +suite: ingress-nginx series do not carry an application identity +templates: + - templates/nginx-scrape.yaml +release: + name: ingress + namespace: tenant-root + +# The vmagent scrape class stamps the scraped pod's application identity on +# every series. ingress-nginx series describe the Ingress objects it serves, +# in whatever namespace they live (honorLabels keeps their namespace), so +# the controller's identity would misattribute them, and with honorLabels +# true an exporter-supplied identity would win over the class. Both +# endpoints drop the identity instead. +tests: + - it: drops the identity on every endpoint + asserts: + - equal: + path: spec.podMetricsEndpoints[0].metricRelabelConfigs + value: + - action: labeldrop + regex: apps_cozystack_io_application_(group|kind|name)