Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion agents/prometheusoperator/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,14 @@ func (agent *PrometheusOperator) CreateOrUpdate(sp api.StatsAccessor, new *api.A
in.Spec.NamespaceSelector = promapi.NamespaceSelector{
MatchNames: []string{sp.GetNamespace()},
}
// Set pod from __meta_kubernetes_pod_name: Prometheus attaches it for both the
// Endpoints and the EndpointSlice discovery role. The role-specific
// __meta_kubernetes_endpoint_address_target_name is empty under EndpointSlice,
// and a replace from an empty source removes the pod label. Regex (.+) leaves
// pod unchanged when the target has no pod name.
podLabel := promapi.RelabelConfig{
SourceLabels: []promapi.LabelName{"__meta_kubernetes_endpoint_address_target_name"},
SourceLabels: []promapi.LabelName{"__meta_kubernetes_pod_name"},
Regex: "(.+)",
TargetLabel: "pod",
Action: "replace",
}
Expand Down
Loading