本篇幅只是回顾使用eureka的时候如何钉钉告警。
Eureka钉钉告警
1 2 3 4
| sequenceDiagram eureka ->> eventListener : event eventListener ->> 钉钉 : alarmNoticeSend 钉钉 ->> 开发人员 : eurekaInstanceInfo
|
关键代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| @EventListener public void listen(EurekaInstanceCanceledEvent event) { log.error("告警通知 [{}] 服务注销 timestamp [{}] serverId [{}]", event.getAppName(), event.getTimestamp(), event.getServerId()); if (!event.isReplication()) { ServiceNotice serviceNotice = new ServiceNotice(); serviceNotice.setTitle("告警通知 服务下线"); serviceNotice.setAppName(event.getAppName()); serviceNotice.setTimestamp(event.getTimestamp()); serviceNotice.setServerId(event.getServerId()); serviceNotice.setProfiles(active); alarmNoticeManage.createNotice(serviceNotice, ""); } }
@EventListener public void listen(EurekaInstanceRegisteredEvent event) { log.info("告警通知 [{}] 服务注册 timestamp [{}] id [{}] ipAddr [{}] ", event.getInstanceInfo().getAppName(), event.getTimestamp(), event.getInstanceInfo().getId(), event.getInstanceInfo().getIPAddr() ); if (!event.isReplication()) { ServiceNotice serviceNotice = new ServiceNotice(); serviceNotice.setTitle("告警通知 服务上线"); serviceNotice.setAppName(event.getInstanceInfo().getAppName()); serviceNotice.setTimestamp(event.getTimestamp()); serviceNotice.setServerId(event.getInstanceInfo().getId()); serviceNotice.setProfiles(active); alarmNoticeManage.createNotice(serviceNotice, ""); } }
|
1 2 3
| 告警通知 服务下线 2020-07-16 16:03:20 Z-GATEWAY 192.168.31.7:z-gateway:9000 profiles dev1 @xxx
|
1 2 3 4 5
| EurekaServerStartedEvent - Eureka服务端启动事件 EurekaRegistryAvailableEvent - Eureka服务端可用事件 EurekaInstanceRegisteredEvent - Eureka客户端服务注册事件 EurekaInstanceRenewedEvent - Eureka客户端续约事件 EurekaInstanceCanceledEvent - Eureka客户端下线事件
|
这里就比较简单了。