From dab6035a97f9e5d960294bc7c24368b75df7f026 Mon Sep 17 00:00:00 2001 From: ZverGuy Date: Thu, 5 Nov 2026 00:17:46 +0700 Subject: [PATCH] fix(ingress): keep application identity off ingress-nginx scrape-health series Dropping the identity in metricRelabelConfigs reaches only the scraped samples. vmagent adds up and scrape_* with the target labels after metric relabeling (VictoriaMetrics v1.136.0 lib/promscrape addAutoMetrics, addRows with needRelabel=false), so those series still carried the controller pod's identity. Dropping it from the target as well leaves every ingress-nginx series with the label set it had before the scrape class. The metric-stage drop stays: with honorLabels true an exporter-supplied identity is not renamed and would otherwise survive. Assisted-by: LLM Signed-off-by: ZverGuy --- packages/extra/ingress/templates/nginx-scrape.yaml | 7 ++++++- .../extra/ingress/tests/application_identity_test.yaml | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/extra/ingress/templates/nginx-scrape.yaml b/packages/extra/ingress/templates/nginx-scrape.yaml index 780f5e3a9..b98f18fe8 100644 --- a/packages/extra/ingress/templates/nginx-scrape.yaml +++ b/packages/extra/ingress/templates/nginx-scrape.yaml @@ -12,7 +12,8 @@ spec: # 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. + # honorLabels an exporter-supplied identity would win over the class. The + # target-stage drop also covers up and scrape_*, which skip metric relabeling. - port: metrics honorLabels: true interval: 30s @@ -23,6 +24,8 @@ spec: targetLabel: node - targetLabel: tier replacement: cluster + - action: labeldrop + regex: apps_cozystack_io_application_(group|kind|name) metricRelabelConfigs: - action: labeldrop regex: apps_cozystack_io_application_(group|kind|name) @@ -53,6 +56,8 @@ spec: targetLabel: controller - targetLabel: tier replacement: cluster + - action: labeldrop + regex: apps_cozystack_io_application_(group|kind|name) metricRelabelConfigs: - action: labeldrop regex: apps_cozystack_io_application_(group|kind|name) diff --git a/packages/extra/ingress/tests/application_identity_test.yaml b/packages/extra/ingress/tests/application_identity_test.yaml index 0e53a2756..4fed325d2 100644 --- a/packages/extra/ingress/tests/application_identity_test.yaml +++ b/packages/extra/ingress/tests/application_identity_test.yaml @@ -10,13 +10,20 @@ release: # 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. +# endpoints drop the identity instead: from the target, because vmagent +# adds up and scrape_* with the target labels after metric relabeling, and +# from the scraped samples, because an exporter's copy is not renamed. tests: - it: drops the identity on every endpoint asserts: - lengthEqual: path: spec.podMetricsEndpoints count: 1 + - contains: + path: spec.podMetricsEndpoints[0].relabelConfigs + content: + action: labeldrop + regex: apps_cozystack_io_application_(group|kind|name) - equal: path: spec.podMetricsEndpoints[0].metricRelabelConfigs value: