twinformatics / eureka-consul-adapter

This project contains a Spring Boot Starter that registers HTTP endpoints on a Spring Cloud Eureka server to support Prometheus's service discovery mechanism for Consul (<consul_sd_config>)
MIT License
102 stars 35 forks source link

How does Eureka, which contains context-path, configure prometheus #22

Closed andyslin closed 4 years ago

andyslin commented 4 years ago

My Eureka Server contains context-path, so configured as consul_sd_configs:-server: localhost:8500/context-path, on prometheus, but in the end prometheus reports about Get http://localhost:8500/context-path%2Fv1/catalog/services.

tine2k commented 4 years ago

Prometheus' consul client does not support a context path. The property you are using is intended for host and port only, not a context path (see https://prometheus.io/docs/prometheus/latest/configuration/configuration/#consul_sd_config). Hence, slashes are escaped.

You could try to use a reverse proxy (like nginx) to add the context path to the requests. This should work as the endpoints of this adapter don't build any paths themselves. All the path logic is done on the client in prometheus.