Skip to content

Set ServiceMonitor pod label from __meta_kubernetes_pod_name - #111

Open
sheikh-arman wants to merge 2 commits into
masterfrom
fix-pod-relabel-endpointslice
Open

sheikh-arman wants to merge 2 commits into
masterfrom
fix-pod-relabel-endpointslice

Conversation

@sheikh-arman

Copy link
Copy Markdown
Member

The pod relabel read __meta_kubernetes_endpoint_address_target_name, which only the Endpoints discovery role sets. With the EndpointSlice role (Prometheus Operator serviceDiscoveryRole: EndpointSlice, Grafana Alloy / k8s-monitoring) that label is empty, and a replace from an empty source removes the pod label the scraper had already set. Every series from a *-stats target then lacks pod, so dashboards that filter on pod show no data.

Read __meta_kubernetes_pod_name instead: Prometheus sets it for pod targets under both roles, and for a pod target its value equals the target name, so Endpoints users get identical series. Regex (.+) keeps an existing pod label when the source is empty.

Add a unit test for the generated relabel config, and vendor the fake clients it uses.

The pod relabel read __meta_kubernetes_endpoint_address_target_name, which only the Endpoints discovery role sets. With the EndpointSlice role (Prometheus Operator serviceDiscoveryRole: EndpointSlice, Grafana Alloy / k8s-monitoring) that label is empty, and a replace from an empty source removes the pod label the scraper had already set. Every series from a *-stats target then lacks pod, so dashboards that filter on pod show no data.

Read __meta_kubernetes_pod_name instead: Prometheus sets it for pod targets under both roles, and for a pod target its value equals the target name, so Endpoints users get identical series. Regex (.+) keeps an existing pod label when the source is empty.

Add a unit test for the generated relabel config, and vendor the fake clients it uses.

Signed-off-by: SK Ali Arman <arman@appscode.com>
Drop agents/prometheusoperator/lib_test.go and re-vendor; the fake clients were only vendored for that test. The change is now only the relabel source in lib.go.

Signed-off-by: SK Ali Arman <arman@appscode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant