Spring Cloud Zuul, Spectator and Atlas config

Viewed 1836

I'm playing with all of this fantastic Spring Cloud stuff on my local machine. I have a Zuul based API-Gateway discovering and calling a Spring Data Rest service. Works great.

Now I want to introduce Spectator and Atlas. I can't seem to get this configured correctly. If I enable Atlas on the Zuul service, the Atlas client's RestTemplate fails because Ribbon tries to wrap it and Ribbon doesn't know about "atlas". If I add a Ribbon Client config for Atlas, then my API Gateway calls break. Is there a way to exclude the atlas route from Ribbon wrapping? What am I missing? See below:

I've define a hostname "atlas" pointed at localhost. Atlas server is running.

Zuul / Api gateway dependencies:

spring-boot-starter-parent: 1.3.2.RELEASE
spring-boot-starter-actuator
spring-cloud-starter-config
spring-cloud-starter-eureka
spring-cloud-starter-hystrix
spring-cloud-starter-zuul
spring-cloud-starter-stream-rabbit
spring-boot-starter-hateoas
spring-boot-starter-test
spring-cloud-starter-spectator
spring-cloud-starter-atlas

Zuul / API Gateway app properties--

hystrix.command.default.execution.isolation.strategy: SEMAPHORE
netflix.atlas.uri=http://atlas:7101/api/v1/publish
server.port: ${PORT:8080}

API Gateway boot properties:

spring.application.name=reservationClient
spring.cloud.config.uri=http://localhost:8888

Zuul / Eureka / Ribbon / Hystrix client all works as expected, but the Atlas client fails.

@SpringBootApplication
@EnableZuulProxy
@EnableHystrix
@EnableEurekaClient
@EnableAtlas
@EnableScheduling
public class APIGateway {

    @Autowired
    Registry registry;

    public static void main(String[] args) {
        SpringApplication.run(APIGateway.class, args);
    }
}

Atlas client is wrapped by Ribbon and Ribbon doesn't know Atlas

2016-03-07 08:57:50.312 ERROR 184 --- [trace=,span=] [ask-scheduler-2] o.s.integration.handler.LoggingHandler   : java.lang.IllegalStateException: No instances available for atlas
    at org.springframework.cloud.netflix.ribbon.RibbonClientHttpRequestFactory.createRequest(RibbonClientHttpRequestFactory.java:58)
    at org.springframework.http.client.support.HttpAccessor.createRequest(HttpAccessor.java:77)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:592)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:557)
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:475)
    at org.springframework.cloud.netflix.metrics.atlas.AtlasMetricObserver.sendMetricsBatch(AtlasMetricObserver.java:148)
    at org.springframework.cloud.netflix.metrics.atlas.AtlasMetricObserver.update(AtlasMetricObserver.java:126)
    at org.springframework.cloud.netflix.metrics.atlas.AtlasExporter.export(AtlasExporter.java:35)
    at org.springframework.boot.actuate.metrics.export.MetricExporters$ExportRunner.run(MetricExporters.java:112)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Ok, let's define a Ribbon client for Atlas.

@SpringBootApplication
@EnableZuulProxy
@EnableHystrix
@EnableEurekaClient
@EnableAtlas
@EnableScheduling
public class APIGateway {

    @Autowired
    Registry registry;

    public static void main(String[] args) {
        SpringApplication.run(APIGateway.class, args);
    }
}

@Component
public class AtlasClientConfiguration {
    @Bean
    public StaticServerList ribbonServerList() {
        return new StaticServerList<Server>(new Server("atlas", 7101));
    }
}

Now the Atlas client is happy. I see POSTs to the Atlas server.
But now my GET requests through Zuul to my Spring Data service, that used to work, are now failing with:

"HTTP method not allowed, supported methods: POST"

Thanks for the help!

1 Answers
Related