-
問題一
各個健康節點許可權問題
解決方式
加入許可權模組
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency>
設定賬戶
security:
user:
name: admin
password: qq123123
management:
security:
roles: SUPERUSER
spring boot admin 配置
eureka: instance: lease-renewal-interval-in-seconds: 10 metadata-map: user.name: ${security.user.name} user.password: ${security.user.password}
呵呵 官方給出的解決方式是放入後設資料中
-
問題二
spring boot admin 排查服務設定問題
boot: admin: routes: endpoints: env,metrics,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,loggers,auditevents,hystrix.stream,activiti turbine: location: dj-atliwen-edi-admin discovery: # ignored-services: turbine ignored-services: ss-erp-*,yjc-zhongjie,*jsp*,admin-discovery
注意!
這裡是小寫!小寫!小寫!
ignored-services 是 Set<Stirng> 注入使用 ,就可以 。 不是 - ss
-
問題三
spring boot admin 自定義訊息觸發器
public class DdNotifier extends AbstractStatusChangeNotifier { private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static RestTemplate template = new RestTemplate(); private String url; DdNotifier(String url) { this.url = url; } @Override protected void doNotify(ClientApplicationEvent event) throws JsonProcessingException { Application a = event.getApplication(); StatusInfo statusInfo = a.getStatusInfo(); switch (statusInfo.getStatus()) { // 健康檢查沒通過 case "DOWN": sendDown(a, statusInfo); break; // 服務離線 case "OFFLINE": offline(a); break; //服務上線 case "UP": up(a); break; // 服務未知異常 case "UNKNOWN": unknown(a); break; default: break; } }
注意!! 這裡是大寫!大寫!大寫! 服務名稱也是大寫!都是大寫!
@Bean @Primary public RemindingNotifier remindingNotifier() { RemindingNotifier notifier = new RemindingNotifier(filteringNotifier()); notifier.setReminderPeriod(TimeUnit.SECONDS.toMillis(600)); String[] reminderStatuses = {"DOWN", "OFFLINE", "UP", "UNKNOWN"}; notifier.setReminderStatuses(reminderStatuses); return notifier; } @Scheduled(fixedRate = 6_000L) public void remind() { remindingNotifier().sendReminders(); }
注意!
setReminderPeriod 設定的不是官方文件上寫的分鐘! 不是分鐘! 是秒!是秒!是秒!
-
問題四
spring boot admin 的 turbine 是在是太慢了!!!! 幾分鐘都不見得好,害我折騰半天,以為是自己哪裡配置沒配置好!!!!