twinformatics / eureka-consul-adapter

This project contains a Spring Boot Starter that registers HTTP endpoints on a Spring Cloud Eureka server to support Prometheus's service discovery mechanism for Consul (<consul_sd_config>)
MIT License
102 stars 35 forks source link

docker swarm #29

Closed Xlinlin closed 4 years ago

Xlinlin commented 4 years ago

Deploy eureka and promethus into Docker swarm, prometheus error msg:

dial tcp: lookup swarm-eureka on 127.0.0.11:53: no such host

tine2k commented 4 years ago

I can only guess. Looks like you got the wrong dns name.

Xlinlin commented 4 years ago
@GetMapping(value = "/v1/catalog/service/{appName}", produces = MediaType.APPLICATION_JSON_VALUE)
public Single<ResponseEntity<List<Service>>> getService(@PathVariable("appName") String appName,
    @QueryParam(QUERY_PARAM_WAIT) String wait,
    @QueryParam(QUERY_PARAM_INDEX) Long index) {
    Assert.isTrue(appName != null, "service name can not be null");
    Single<ChangeItem<List<InstanceInfo>>> service = registrationService.getService(appName, getWaitMillis(wait), index);

    return registrationService.getService(appName, getWaitMillis(wait), index)
        .map(item -> {
            List<Service> services = item.getItem().stream().map(instanceInfoMapper::map).collect(toList());
            // docker swarm,use instance id(dns)
            if (dockerSwarm) {
                services.forEach(service1 -> {
                    **String serviceId = service1.getServiceID();
                    String[] split = serviceId.split(":");
                    service1.setAddress(split[0]);
                    service1.setServiceAddress(serviceId);**
                });
            }
            return createResponseEntity(services, item.getChangeIndex());
        });
}

But,I got another error: Eureka: w.s.m.s.DefaultHandlerExceptionResolver Resolved [org.springframework.web.context.request.async.AsyncRequestTimeoutException]

Xlinlin commented 4 years ago

Promethus: level=error ts=2020-06-09T06:35:26.433Z caller=consul.go:487 component="discovery manager scrape" discovery=consul msg="Error refreshing service" service=SWARM-CONSUMER tags= err="Unexpected response code: 503 ({\"timestamp\":\"2020-06-09T06:35:26.432+0000\",\"status\":503,\"error\":\"Service Unavailable\",\"message\":\"No message available\",\"path\":\"/v1/health/service/SWARM-CONSUMER\"}

tine2k commented 4 years ago

Have a look at the required timeout configuration in the Readme.

Xlinlin commented 4 years ago

Thanks