服务有context-path如何解决?
Closed this issue · 3 comments
alang124 commented
服务有context-path如何解决?
chen-gliu commented
在Prometheus的配置上加上对应的context-path就好了
alang124 commented
在Prometheus的配置上加上对应的context-path就好了
不同的服务context-path不一样啊?
metrics_path不是整个job的配置是一样吗
我现在有3个服务
服务1 context-path是 /a
服务2 context-path是 /b
服务3 context-path是 /
我没弄明白应该怎么样配置
chen-gliu commented
scrape_configs:
- job_name: 'spring-cloud'
consul_sd_configs:- server: ':'
services: ['']
metrics_path: '/actuator/prometheus'
relabel_configs: - source_labels: [__meta_consul_tags]
regex: .*
action: keep - source_labels: [address, __meta_consul_service]
target_label: metrics_path
replacement: '/$2/actuator/prometheus'
- server: ':'
你可以通过打标签的方式配置。将context path通过标签传到Prometheus,然后Prometheus将这个标签内容替换metrics_path。当然我这里的名称是随便设置的,你要根据你标签实际的名称修改这个配置哈。