-
问题一
各个健康节点权限问题
解决方式
加入权限模块
<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 是在是太慢了!!!! 几分钟都不见得好,害我折腾半天,以为是自己哪里配置没配置好!!!!