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: