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
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
I am trying to get my microservices configuration from a config server connected to 2 sources : git and vault (for secrets). I have the config bellow:
in the config-server:
server:
port: 8888
spring:
profiles:
active: git, vault
cloud:
config:
server:
vault:
port: 8200
host: 127.0.0.1
kvVersion: 2
git:
order: 2
uri: git#gitlab.git
and in the client side in the bootstrap.yml:
spring:
application:
name: my-service-name
cloud:
config:
uri: http://localhost:8888
token: //token
label: dev
But in my vault i have the path like this :
secret/cad
|--my-service-name
When i make my secret directly in /secret/my-service-name i can access my secrets, but how can i configure acces to secrets in : /secret/cad/my-service-name
Thank you.
You can create your Custom configuration Class that implements VaultConfigurer where you can override to your custom path
#Configuration
Public class CustomVaultConfiguraton implements VaultConfigurer {
#override
public void addSecretsBackends(SecretBackendConfigurer configures){
configures.add("customPath");
}
}
add above configuration class in spring.factories
org.springframework.cloud.bootstrap.BootstrapConfiguration=\packagename.CustomVaultConfiguration
We are trying to register a spring-cloud-consul application with consul on GCP compute engine, where it is able to register the application with the consul, but there are two problems we are facing with the application. Below is bootstrap.yaml and server.yaml for the application,
application.yaml
server:
port: 10003
spring:
application:
name: hello-service
cloud:
consul:
enabled: true
inetutils:
useOnlySiteLocalInterfaces: true
endpoints:
actuator:
sensitive: false
bootstrap.yaml
spring:
cloud:
consul:
enabled: true
host: 10.160.0.18
port: 8500
discovery:
prefer-ip-address: true
Consul is not able to call health-check on compute engine, possibly because it's registered on the internal domain name of the instance.
service with consul: NewService{id='hello-service-10003',
name='hello-service', tags=[secure=false],
address='consul-app-test.c.name-of-project.internal', meta=null,
port=10003, enableTagOverride=null, check=Check{script='null',
interval='10s', ttl='null',
http='http://consul-app-test.c.name-of-project.internal:10003/actuator/health',
method='null', header={}, tcp='null', timeout='null',
deregisterCriticalServiceAfter='null', tlsSkipVerify=null,
status='null'}, checks=null}
Application, not de-registering from the consul. We have stopped the application still it shows on consul UI.
I made a few changes in the application.yaml and bootstrap.yaml which worked for me.
application.yaml
spring:
application:
name: hello-service
cloud:
consul:
discovery:
instanceId: ${spring.application.name}:${random.value}
health-check-critical-timeout: 3m
prefer-ip-address: true # disable if we want to use google cloud internal DNS
bootstrap.yaml
spring:
cloud:
consul:
enabled: true
host: 10.160.0.18
port: 8500
if you use version 2.1.2 like me: org.springframework.cloud:spring-cloud-starter-consul-discovery:2.1.2.RELEASE
you can set:
spring:
cloud:
consul:
host: localhost # consul的地址
port: 8500 # consul 的端口
discovery:
prefer-ip-address: true # // This must be matched
tags: version=1.0
instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}
healthCheckPath: /actuator/health # 服务做健康检查的端口
healthCheckInterval: 15s # 服务健康检查的周期
healthCheckTimeout: 60s # 服务检查是的timeout时长
healthCheckCriticalTimeout: 5m # 服务健康检查失败5分钟后,删除服务
and you can look the source code in ConsulDiscoveryProperties:
#ConfigurationProperties("spring.cloud.consul.discovery")
public class ConsulDiscoveryProperties {
……
/** Is service discovery enabled? */
private boolean enabled = true;
/** Alternate server path to invoke for health checking. */
private String healthCheckPath = "/actuator/health";
/** Custom health check url to override default. */
private String healthCheckUrl;
/** How often to perform the health check (e.g. 10s), defaults to 10s. */
private String healthCheckInterval = "10s";
/** Timeout for health check (e.g. 10s). */
private String healthCheckTimeout;
/**
* Timeout to deregister services critical for longer than timeout (e.g. 30m).
* Requires consul version 7.x or higher.
*/
private String healthCheckCriticalTimeout;
……
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