Skip to content

Commit

Permalink
vmagent/servicescrape: add missing container name label
Browse files Browse the repository at this point in the history
Previously `container` label wasn't added for `endpointslices` discovery role.
But this label exists at `endpoints` role, which supposed to be the same discovery roles.
But endpointslices is optimised API version.

 This commit properly adds `container` label for metrics discovered with `VMServiceScrape.spec.discoveryRole: endpointslices`.

Signed-off-by: f41gh7 <[email protected]>
  • Loading branch information
f41gh7 committed Nov 19, 2024
1 parent 1e7c2c5 commit 95dcedf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 4 additions & 0 deletions internal/controller/operator/factory/vmagent/servicescrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 95dcedf

Please sign in to comment.