Difference between endpoints and endpointslice scraping roles with ipFamilyPolicy: PreferDualStack

59 views
Skip to first unread message

Vu Nguyen

unread,
Sep 11, 2025, 4:25:26 AMSep 11
to Prometheus Users
I’m testing Prometheus service discovery on a dual-stack Kubernetes cluster where the service has ipFamilyPolicy set to PreferDualStack. When using the deprecated endpoints scraping role, Prometheus discovers targets only with the IPv4 address.

However, when switching to the endpointslice scraping role with the same relabeling rules, Prometheus discovers targets with both IPv4 and IPv6 addresses for the same service.

```
up{instance="ipv4:9089", job="endpointslice-role", namespace="test-ns", pod_name="testapp-5f58b46757-nq7hx", service_name="testapp-prefer-dualstack"} 1
up{instance="ipv6:9089", job="endpointslice-role", namespace="test-ns", pod_name="testapp-5f58b46757-nq7hx", service_name="testapp-prefer-dualstack"} 1
up{instance="ipv4:9089", job="endpoints-role", namespace="test-ns", pod_name="testapp-5f58b46757-nq7hx", service_name="testapp-prefer-dualstack"} 1
```

Is this behavior expected? Should Prometheus handle dual-stack targets differently when scraping endpointslice vs endpoints? Are there any best practices or configuration nuances to be aware of when migrating from endpoints to endpointslice in a dual-stack environment?

Thanks in advance for any insights!

Best Regards, Vu

Vu Nguyen

unread,
Sep 12, 2025, 5:15:09 AMSep 12
to Prometheus Users

Additionally, I’ve noticed that when the metric port is not declared in the Service manifest where the Prometheus annotations are placed, this duplication of scraping (both IPv4 and IPv6 targets) from the Endpointslice role does not occur.

Does this mean that explicitly specifying the metric port in the Service manifests influences how Endpointslice targets are discovered and scraped?

Any further clarification on how the metric port declaration interacts with dual-stack service discovery in Prometheus would be highly appreciated.

Vu Nguyen

unread,
Oct 3, 2025, 3:02:14 AM (13 days ago) Oct 3
to Prometheus Users
Hi,

Do you have any suggestions on how to prevent duplicate scraping when using the endpointslice role in this scenario? Could this be resolved with a relabeling rule?

For your reference, I’ve opened an issue on the Prometheus GitHub repository: https://github.com/prometheus/prometheus/issues/17193

Regards, Vu
Reply all
Reply to author
Forward
0 new messages