Eureka Server Health Not Running - spring-cloud

I updated a eureka server from Camdem.R3 to Flinchley.RC1 lately. There were a lot of changes in the settings.
On Camden.R3, without doing any additional settings the console link to the health check would work. For Flinchley.RC1 the health check would give a 404 response. I am trying to read the latest settings in Flinchley document but it only states how to check the health. Is there a way to find out if the client really ran the health check context?

After several research, I found out that the spring boot actuator specs was changed for 2.0. For Camden.R3 which is compatible with spring boot 1.X, all actuators starts in the base context. While Flinchley.RC1 which is compatible with spring boot 2.0 all context requires a context prefix of "/actuator".
Spring Boot 1.X actuator:
All of the actuator endpoints "sub sites" are turned on by default.
Health actuator would give a more detailed information in its
response
The actuator starts on base context of Eureka Client Site (e.g. localhost:8080/health)
Spring Boot 2.0 actuator:
Only the health and info are turned on by default.
Health actuator would give a simple answer of UP / DOWN. To show others you need to set them in configuration.
All actuator must have the endpoint prefix in URL. The default prefix
is "actuator" (e.g. http://localhost:8080/actuator/health)
See the following sites for more details:
Spring Boot Actuator (very detailed explanation)
Spring Boot Actuator 1.X Official Document
Spring Boot Actuator 2.0 Official Document

Related

correlationId propagated to spring sleuth 1.x

I have the following setup:
Proxy (P) -- HTTP --> Spring Boot 2 app (X) -- HTTP --> Spring Boot 1 app (Y)
The proxy sends the requestId as an HTTP header which I need to include in the logs of both X and Y.
For the X app I could easily do it with the support of Spring Cloud Sleuth 2 using
spring:
sleuth:
propagation-keys: requestId
and creating a CurrentTraceContext implementation with inspiration from Slf4jCurrentTraceContext where I add
MDC.put("requestId", ExtraFieldPropagation.get(currentSpan, "requestId"));
and then I can easily add it to the logs using the following log pattern:
%d{yy-MM-dd E HH:mm:ss.SSS} %5p [component=${springAppName},requestId=%X{requestId:-}] %m%n"
But now I need to propagate the requestId also to Y app.
Unfortunately there I cannot leverage the goodies introduced in Spring Cloud Sleuth 2.0, (like TraceContext from brave library) since that is a Spring Boot 1.x app.
Wondering what are the options?
I was thinking to extend the Slf4jSpanLogger and inject into DefaultTracer but not sure how to get the requestId there is no TraceContext in SpanLogger.
requestId has to be there in the headers. You would have to modify the current logic of parsing the HTTP headers for Boot 1.x and retrieve that value from the headers and put it in the span.
The easiest way however would be to propagate that value as baggage cause baggage works out of the box for Boot 1.x. That way if we see the baggage- prefixed headers, Sleuth 1.3.x will automatically propagate it. Remember to whitelist the baggage in Boot 2.0.

Can a Spring Cloud Gateway App be Enabled as a Cloud Config Server?

I'm trying to enable a Spring Cloud Gateway app to automatically refresh its routing config yml on the fly. I have been able to set up a Cloud Config server to host the route YAML and enabled the Spring Cloud Gateway to automatically refresh its config via a #Scheduled contextRefresher.refresh() usage. However, this requires two running apps, and we want to try to minimize the number of additional servers needed to support this requirement.
The Spring Cloud Config Server documentation suggests any boot app can be embedded with a config server via the #EnableConfigServer annotation: https://cloud.spring.io/spring-cloud-static/spring-cloud.html#_spring_cloud_config_server
However, when attempting to introduce the spring-cloud-config-server module in my Gateway's build.gradle, I run into the following error on startup:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.http.codec.ServerCodecConfigurer' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
From the discussion here (https://github.com/spring-cloud/spring-cloud-gateway/issues/319) it seems that the issue above arises because spring-boot-starter-web is incompatible w/ Gateway; Gateway is a Netty app and spring-boot-starter-web uses tomcat/servlets. When trying to exclude spring-boot-starter-web from the cloud-config-server module, the app fails again w/:
onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.cloud.config.server.config.ConfigServerAutoConfiguration]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/web/servlet/config/annotation/WebMvcConfigurerAdapter.class] cannot be opened because it does not exist
Is it the case that a Spring Cloud Gateway app cannot be enabled as a CloudConfig server? Or am I missing something.
FWIW my sprincCloudVersion is Finchley.SR1
They can not. Config server is based on spring MVC (servlets), gateway is based on spring webflux and Netty. They are not compatible and cannot be run together.

Spring boot Admin Slack notification

Migrated our stack to Spring Boot 2.0.3 and switched our spring boot admin. Everything is working, microservices are registering (hats off codecentric)
Only issue is that we are not getting any slack notification when services are down or up, what is different from earlier versions (which was working fine)
we are using same config as before:
spring.boot.admin.notify.slack.enabled=true
spring.boot.admin.notify.slack.username=Spring Boot Admin Service
spring.boot.admin.notify.slack.message=*#{application.name}* (#
{application.id}) is *#{to.status}*
spring.boot.admin.notify.slack.icon=:bender:
and the web hook url in yaml file
spring:
profiles: production
boot:
admin:
notify:
slack:
webhook-url: xxx
Any help appreciated
Was struggling with this same issue when I spotted this question, we recently moved from Spring Boot Admin 1.5.4 up to 2.0.2 with a similar version bump for Spring Boot (1.5.9 -> 2.0.4) and I'd recently noticed that slack notifications had stopped working.
Checking our Spring Boot Admin server logs I could the following exception was thrown when a monitored client went offline : "SpelEvaluationException: EL1008E: Property or field 'application' cannot be found" so it seems that the syntax for the slack message had changed.
Was just about to post in the codecentric mailing list when I decided to double check the docs for 2.0.4 Slack notifications and voila the syntax for spring.boot.admin.notify.slack.message had changed from
"#{application.name} (#{application.id}) is #{to.status}"
to
"#{instance.registration.name} (#{instance.id}) is
#{event.statusInfo.status}"
TLDR: RTFM

Is it possible to define a static server list with ribbon (via feign) when Eureka is in use?

Environment
Spring Boot 1.5.13.RELEASE
Spring Cloud Edgware.SR3
Java 8
Configuration
Eureka client is enabled and working correctly (I have tested and everything's working as I expect).
Some relevant properties from my configuration:
feign.hystrix.enabled=true
eureka.client.fetch-registry=true
spring.cloud.service-registry.auto-registration.enabled=true
service1.ribbon.listOfServers=https://www.google.com
Context
I have an application which speaks to 3 other services using feign clients. Two of these are discovered via Eureka service discovery. These are working well. The final service is an external one with a single static hostname and I do not want this resolved via Eureka. Since I do want Eureka for 2 of these services I would like to keep Eureka enabled.
Question
For the final service I tried adding service1.ribbon.listOfServers=https://www.google.com to the application.properties, however this cases the following error at runtime when invoking the feign client:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.netflix.hystrix.exception.HystrixRuntimeException: Service1Client#test() failed and no fallback available.] with root cause
pricing_1 |
pricing_1 | com.netflix.client.ClientException: Load balancer does not have available server for client: service1
pricing_1 | at com.netflix.loadbalancer.LoadBalancerContext.getServerFromLoadBalancer(LoadBalancerContext.java:483) ~[ribbon-loadbalancer-2.2.5.jar!/:2.2.5]
My client is configured as follows:
#FeignClient("service1")
public interface Service1Client {
#GetMapping(value = "/")
String test();
}
Thanks in advance for any advice.
Consideration
Since the spirit of Ribbon as I understand it is to act as a client side load balancer and given in my case there is nothing to load balance (I have one fixed static hostname that returns a single A record in DNS). Ribbon actually feels like an unnecessary component - what I really wanted was the Feign client as I like the fact that it abstracts away the lower level HTTP request and object seralization. So I suppose an alternative follow up question is, can I use feign without ribbon - it seems the nice out of the box behaviour would be to use ribbon - even the Javadoc of the #FeignClient annotation says:
If ribbon is available it will be
used to load balance the backend requests, and the load balancer can be configured
using a #RibbonClient with the same name (i.e. value) as the feign client.
suggesting the two are quite closely related even if they are serving different purposes.
As you mentioned, there are two ways to solve your problem.
Use Feign without Ribbon
If you specify url attribute in #FeignClient annotation, it will work without Ribbon like the below.
#FeignClient(name = "service1", url = http://www.google.com)
public interface Service1Client {
#GetMapping(value = "/")
String test();
}
In this case, your other two Feign client will still work with Ribbon and Eureka.
Use Feign with Ribbon and without Eureka
What you are missing is in your configuration is NIWSServerListClassName.
Its default value is com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList and it will use Eureka to retrieve the list of server. If you set NIWSServerListClassName to ConfigurationBasedServerList for a ribbon client (feign client), only that client will work with listOfServers list without retrieving server list from Eureka. And other feign clients will still work with Eureka.
service1:
ribbon:
NIWSServerListClassName: com.netflix.loadbalancer.ConfigurationBasedServerList
listOfServers: http://www.google.com

Spring Cloud Stream Rabbit Binder Routing Key always '#'

Version: Spring Boot: 1.4.2.RELEASE
Spring Cloud Deps: Brixton.SR7
Here is my application.properties of a processor app.
logging.level.=DEBUG
server.port=0
logging.file=traveller-events-processor.log
server.port=0
spring.cloud.stream.rabbit.bindings.input.consumer.bindingRoutingKey='aa'
spring.cloud.stream.rabbit.bindings.input.consumer.bindingRoutingKey=aa
spring.cloud.stream.rabbit.bindings.input.consumer.bindQueue=true
spring.cloud.stream.rabbit.bindings.input.consumer.routing-key='aa'
spring.cloud.stream.rabbit.bindings.input.consumer.routingKey='aa'
spring.cloud.stream.bindings.input.destination=events-exchange
spring.cloud.stream.bindings.input.group=eventconsumersgroup
spring.cloud.stream.bindings.output.destination=work.out
spring.cloud.stream.bindings.output.contentType=text/plain
spring.cloud.stream.bindings.output.binder=rabbit
spring.cloud.stream.bindings.output.group=traveller-events-output-group
When I start this app, events-exchange is created as expected and bound to a queue named: events-exchange.eventconsumersgroup (which is also ok). But the routingKey is always '#'. I've tried with all the options I have fished from various documentations. Am I missing something here?
I want this app to only subscribe to certain messages (which I want to achieve via the routing key).
I see that Brixton.SR7 uses 1.0.2.RELEASE of Spring Cloud Stream and I don't seem to find the routingKey as a Rabbit consumer property. Do you want to upgrade to Spring Cloud Camden release or the latest one so that you can try using the consumer property: bindingRoutingKey as mentioned here