diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b864f83e..e26ba130 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -13,6 +13,7 @@ aliases: ## tip +- [vmoperator](https://docs.victoriametrics.com/operator/): add missing `container` labels to the metrics discovered with `VMServiceScrape` for `endpointslices` discovery role. - [vmoperator](https://docs.victoriametrics.com/operator/): bump default version of VictoriaMetrics components to [1.106.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.106.1). - [vmoperator](https://docs.victoriametrics.com/operator/): add new variable `VM_VMSERVICESCRAPEDEFAULT_ENFORCEENDPOINTSLICES` to use `endpointslices` instead of `endpoints` as discovery role for VMServiceScrape when generate scrape config for VMAgent. diff --git a/internal/controller/operator/factory/vmagent/servicescrape.go b/internal/controller/operator/factory/vmagent/servicescrape.go index d64d726c..a85bbca5 100644 --- a/internal/controller/operator/factory/vmagent/servicescrape.go +++ b/internal/controller/operator/factory/vmagent/servicescrape.go @@ -116,6 +116,10 @@ func generateServiceScrapeConfig( {Key: "source_labels", Value: []string{"__meta_kubernetes_pod_name"}}, {Key: "target_label", Value: "pod"}, }, + { + {Key: "source_labels", Value: []string{"__meta_kubernetes_pod_container_name"}}, + {Key: "target_label", Value: "container"}, + }, }...) case kubernetesSDRoleEndpoint: // Relabel namespace and pod and service labels into proper labels. diff --git a/internal/controller/operator/factory/vmagent/servicescrape_test.go b/internal/controller/operator/factory/vmagent/servicescrape_test.go index 98be68ce..a8a4c0ba 100644 --- a/internal/controller/operator/factory/vmagent/servicescrape_test.go +++ b/internal/controller/operator/factory/vmagent/servicescrape_test.go @@ -440,6 +440,9 @@ relabel_configs: - source_labels: - __meta_kubernetes_pod_name target_label: pod +- source_labels: + - __meta_kubernetes_pod_container_name + target_label: container - source_labels: - __meta_kubernetes_namespace target_label: namespace