Zookeeper 普罗米修斯:发现的服务地址为空?

cig3rfwq  于 2022-12-09  发布在  Apache
关注(0)|答案(2)|浏览(139)

我已经编写了一个非常基本的Sping Boot 2应用程序,它连接到Zookeeper以进行服务发现(通过使用spring-cloud-starter-zookeeper-discovery)。
应用程序使用以下值在/services/example-service注册:

{"name":"example-service","id":"cb14ad15-4d33-4f1c-a420-29980ddf2fa8","address":"bf3fb9191373","port":8080,"sslPort":null,"payload":{"@class":"org.springframework.cloud.zookeeper.discovery.ZookeeperInstance","id":"application-1","name":"example-service","metadata":{}},"registrationTimeUTC":1524120820273,"serviceType":"DYNAMIC","uriSpec":{"parts":[{"value":"scheme","variable":true},{"value":"://","variable":false},{"value":"address","variable":true},{"value":":","variable":false},{"value":"port","variable":true}]}}

地址是一个id,因为我已经用Docker部署了堆栈。
我的Prometheus配置如下所示:

- job_name: 'example-service'
  metrics_path: '/actuator/prometheus'
  serverset_sd_configs:
  - servers:
    - zookeeper:2181
    paths:
    - '/services/example-service'

Prometheus的服务发现页面显示以下发现的标签:

__address__=":0"  __meta_serverset_endpoint_host=""  __meta_serverset_endpoint_port="0" __meta_serverset_path="/services/example-service/cb14ad15-4d33-4f1c-a420-29980ddf2fa8"  __meta_serverset_shard="0"  __meta_serverset_status="" __metrics_path__="/actuator/prometheus"  __scheme__="http"  job="example-service"

知道为什么__address__:0吗?

jmp7cifd

jmp7cifd1#

服务器集发现是一个particular way of using Zookeeper,您的应用程序没有遵循它。在这种情况下,您可能需要file service discovery

kmynzznz

kmynzznz2#

服务器设置使用配置如下:

{"serviceEndpoint":{"host":"localhost","port":9100},"additionalEndpoints":{},"status":"ALIVE"}

相关问题