From 0e5557d0baef802125b88d438d741055da5ee408 Mon Sep 17 00:00:00 2001 From: ZverGuy Date: Wed, 4 Nov 2026 04:26:04 +0700 Subject: [PATCH] fix(ingress): keep application identity off ingress-nginx series The vmagent scrape class stamps the scraped pod's application identity on its series. ingress-nginx series describe the Ingress objects the controller serves, in whatever namespace they live, so the controller's own identity would attribute another tenant's traffic to the Ingress application. And because these scrapes honor exporter labels, an exporter-supplied identity would win over the class. Dropping the labels leaves these series to the pod and namespace scopes. Assisted-by: LLM Signed-off-by: ZverGuy --- .../extra/ingress/templates/nginx-scrape.yaml | 10 +++++++++ .../tests/application_identity_test.yaml | 21 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 packages/extra/ingress/tests/application_identity_test.yaml 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)