【问题标题】:Prometheus: Address of discovered service is empty?Prometheus:发现服务的地址为空?
【发布时间】:2018-09-29 14:37:42
【问题描述】:

我编写了一个非常基本的 Spring 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吗?

【问题讨论】:

    标签: spring-boot apache-zookeeper prometheus


    【解决方案1】:

    Serverset 发现是一个particular way of using Zookeeper,您的应用程序没有关注它。在这种情况下,您可能需要file service discovery

    【讨论】:

    • 正在写入的服务信息类型为org.apache.curator.x.discovery.ServiceInstance,与serverset不兼容。感谢您将我推向正确的方向。
    【解决方案2】:

    Serverset 使用配置如下:

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

    【讨论】:

      猜你喜欢
      • 2018-03-07
      • 1970-01-01
      • 2018-07-07
      • 2023-03-22
      • 2017-06-09
      • 1970-01-01
      • 1970-01-01
      • 2012-03-25
      • 1970-01-01
      相关资源
      最近更新 更多