Discovery Client not initialized for Spring Health Actuator - spring

I am trying to run a Spring boot application which is OpenAPI Generated. I have set the following configurations in my application.yml
# Actuator Configuration
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
enabled: true
health:
defaults:
enabled: false
refresh:
enabled: false
db:
enabled: false
diskspace:
enabled: false
vault:
enabled: false
health:
config:
enabled: false
But when I run the endpoint /actuator/health, I am getting the following response:
{
"description": "Discovery Client not initialized",
"status": "UNKNOWN"
}
NOTE:
Spring Boot Version: 2.2.1.RELEASE

Related

Spring boot config server does not refresh if I update local

I have Spring cloud project which has below information:
Controller of address-service-1:
#RestController
#RequestMapping("/api/address")
#Slf4j
#RefreshScope
public class AddressController {
#Value("${scope-refresh-testing}")
private String message;
#RequestMapping("/scope-refresh-testing-message")
String getMessage() {
return this.message;
}
}
bootstrap.yml of address-service-1:
spring:
application:
name: address-service-1
# register to config server
cloud:
config:
discovery:
enabled: true
service-id: config-server-1
profile: default
management:
endpoints:
web:
exposure:
include:
- refresh
Properties of config-server-1:
server:
port: 8888
spring:
application:
name: config-server-1
cloud:
config:
server:
git:
default-label: master
uri: file:///E:/workspace/Spring-boot-microservices-config-server-study/
Properties which I stored in file:///E:/workspace/Spring-boot-microservices-config-server-study/ (address-service-1.yml):
scope-refresh-testing: testDefault
If I change scope-refresh-testing: testDefault222 then run url actuator/refresh, the properties file will rollback to scope-refresh-testing: testDefault
Did I miss something in configuration?
Thanks

Name or service unknow with eureka server

I use spring boot with eureka.
When I try to start the eureka server, I get
Caused by: java.net.UnknownHostException: MiWiFi-RA72-srv: Name or
service not known
My config
server:
port: 8761
spring:
security:
user:
name: admin
password: password
logging:
level:
org:
springframework:
security: DEBUG
eureka:
client:
registerWithEureka: false
fetchRegistry: false
service-url:
defaultZone: http://admin:password#localhost:8761/eureka/
server:
waitTimeInMsWhenSyncEmpty: 0
instance:
hostname: localhost
prefer-ip-address: true
I tried to replace localhost by MiWiFi-RA72-srv, but I get the same result

Eureka preferIpAddress: true is not working with spring boot 2.1.3 'Greenwich.RELEASE' '

Due to some reasons, I want microservices clients to be registered into Eureka with their IP address, instead of host name.
This is not working even after setting eureka: instance: preferIpAddress: true [yaml given below].
Still eureka display only host names. Anyone faced this type of issue and possible remedy would be really helpful.
Springbootversion : 2.1.3 , Spring cloud - Greenwich Release
application.yml of microservice instance Please note the preferIpAddress: true
spring:
profiles: default
application:
name: booking
cloud:
config:
uri: http://localhost:8888,http://localhost:8889
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:8761/eureka
healthcheck:
enabled: false
instance:
leaseRenewalIntervalInSeconds: 1
leaseExpirationDurationInSeconds: 2
preferIpAddress: true
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
security:
enabled: false
application.yml of Eureka server
spring:
profiles: localpeer1
eureka:
server:
client:
register-with-eureka: false
fetch-registry: false
serviceUrl:
defaultZone: http://localhost:8762/eureka
server:
port: 8761
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
---
spring:
profiles: localpeer2
eureka:
server:
client:
register-with-eureka: false
fetch-registry: false
serviceUrl:
defaultZone: http://localhost:8761/eureka
server:
port: 8762
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
Dashboard of Eureka still shows the hostname instead of IP address.
Thanks for the inputs.

Eureka Server and Spring Boot Admin in one Application

I try to run Eureka Server and Spring Boot Admin Server in one Application (SBA Docu says this is possible). Eureka is working as intended but the Admin App still shows zero Applications.
Spring Boot Version 2.0.3,
Spring Boot Admin Version 2.0.1
Eureka and SBA Server
#SpringBootApplication
#EnableEurekaServer
#EnableDiscoveryClient
#EnableAdminServer
class KotlintestApplication
fun main(args: Array<String>) {
SpringApplication.run(KotlintestApplication::class.java, *args)
}
Server bootstrap.yml
spring:
application:
name: server
Server application.yml
spring:
boot:
admin:
context-path: /admin
eureka:
instance:
leaseRenewalIntervalInSeconds: 10
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://localhost:8080/eureka
Client
#EnableDiscoveryClient
#SpringBootApplication
class KotlintestApplication
fun main(args: Array<String>) {
SpringApplication.run(KotlintestApplication::class.java, *args)
}
#Configuration
class SecurityPermitAllConfig : WebSecurityConfigurerAdapter() {
#Throws(Exception::class)
override fun configure(http: HttpSecurity) {
http.authorizeRequests().anyRequest().permitAll()
.and().csrf().disable()
}
}
Client bootstrap.yml
spring:
application:
name: client
server:
port: 0
Client application.yml
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
eureka:
instance:
hostname: localhost
health-check-url-path: /actuator/health
status-page-url-path: /actuator/info
client:
serviceUrl:
defaultZone: http://127.0.0.1:8080/eureka/
Found the answer myself
Remove the fetchRegistry: false from the server application.yaml.
The Server has to fetch the registry to see the clients ...
Btw: You should set an instanceId if you want to run multiple instances with a random port on the same host. Otherwise SBA can't differ between the instances.
eureka:
instance:
instanceId : client-${random.uuid}

How to add into Turbine additional Hystrix metrics aggregations

My setup is spring boot cloud using netflix library
I managed to have Turbine aggregating Hystrix metrics from one service. However when I add more services I cant see them.
This is my setup (also uploaded this into github at:
Project On Github
Service 1:
FlightIntegrationService:
#SpringBootApplication
#EnableCircuitBreaker
#EnableDiscoveryClient
#ComponentScan("com.bootnetflix")
public class FlightIntegrationApplication {
..
}
application.yaml
server:
port: 0
eureka:
instance:
leaseRenewalIntervalInSeconds: 10
metadataMap:
instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${random.value}}}
client:
registryFetchIntervalSeconds: 5
bootstrap.yaml
spring:
application:
name: flight-integration-service
service 2:
Coupon service:
#SpringBootApplication
#EnableCircuitBreaker
#EnableDiscoveryClient
#ComponentScan("com.bootnetflix")
public class CouponServiceApp {
..
}
application yaml:
server:
port: 0
eureka:
instance:
leaseRenewalIntervalInSeconds: 10
metadataMap:
instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${random.value}}}
client:
registryFetchIntervalSeconds: 5
Eureka app service:
#SpringBootApplication
#EnableEurekaServer
public class EurekaApplication {
Hystrix dashboard service:
#SpringBootApplication
#EnableHystrixDashboard
#Controller
public class HystrixDashboardApplication {
application.yaml:
info:
component: Hystrix Dashboard
endpoints:
restart:
enabled: true
shutdown:
enabled: true
server:
port: 7979
logging:
level:
ROOT: INFO
org.springframework.web: DEBUG
eureka:
client:
region: default
preferSameZone: false
us-east-1:
availabilityZones: default
instance:
virtualHostName: ${spring.application.name}
bootstrap.yaml
spring:
application:
name: hystrixdashboard
and finally Turbine-service:
EnableAutoConfiguration
#EnableTurbine
#EnableEurekaClient
#EnableHystrixDashboard
public class TurbineApplication {
application.yaml:
info:
component: Turbine
PREFIX:
endpoints:
restart:
enabled: true
shutdown:
enabled: true
server:
port: 8989
management:
port: 8990
eureka:
instance:
leaseRenewalIntervalInSeconds: 10
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
#turbine:
# aggregator:
# clusterConfig: FLIGHT-INTEGRATION-SERVICE,COUPON-SERVICE
#appConfig: flight-integration-service,coupon-service
#turbine:
# clusterNameExpression: 'default'
# appConfig: flight-integration-service,coupon-service
turbine:
appConfig: coupon-service,flight-integration-service
clusterNameExpression: new String('default')
#As you can see I tried diff configurations.
What am i doing wrong? why I cant actually aggregate both services hystrix metrics(flight-integration service,coupon-service)
Thank you.
solved by #spencergibb suggestation. I added to each of the client the dependency of spring-boot-starter-amqp and created rabbitMQ broker. Turbine is aggregating all messages via amqp and I was able to see all Hystrix commands aggregated on my hystrix dashboard server

Resources