Closed kukuxiahuni closed 5 years ago
If you want to explicitly set the base path for all services with the sd mechanism, you can just hardcode it in prometheus.yml like so: metrics_path: /mybasepath/actuator/prometheus
.
If you have a different base path for each service, you need to send the base path along with the eureka discovery registration (see https://projects.spring.io/spring-cloud/spring-cloud.html#_eureka_metadata_for_instances_and_clients). As soon as it is available in eureka, prometheus will get this metadata (as something like __meta_consulmetadata...). Based on this, you can use the relabeling feature of prometheus to set the correct metrics path for the service (see https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config).
if spring boot service have servlet.contextPath and managed by eureka, how to config it in prometheus.yml?