Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
263 views
in Technique[技术] by (71.8m points)

spring boot - Prometheus: Address of discovered service is empty?

I've written a very basic Spring Boot 2 application that connects to Zookeeper for service discovery (by using spring-cloud-starter-zookeeper-discovery).

The application gets registered at /services/example-service with the following value:

{"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}]}}

The address is an id because I've deployed the stack with Docker.

My Prometheus configuration looks like this:

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

The service discovery page of Prometheus shows the following discovered labels:

__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"

Any idea why __address__ is :0?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Serverset discovery is a particular way of using Zookeeper, which your application is not following. In this case you probably want file service discovery.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...