提交 adabfc53 authored 作者: 杨凯's avatar 杨凯

feat:新增告警接收接口

上级 9093a9fd
......@@ -4,6 +4,9 @@ import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
* ProjProperties
......@@ -17,8 +20,6 @@ import org.springframework.stereotype.Component;
@ConfigurationProperties(prefix = "projprops")
public class ProjProperties {
private String cloudBaseService;
private String cloudBaseNotifyName;
private List<ServiceInfo> serviceInfo;
}
package com.ebaiyihui.alarm.server.config;
import lombok.Data;
/**
* @description:
* @author: yk
* @create: 2023/08/10 14:39
**/
@Data
public class ServiceInfo {
private String serviceNames;
private String serviceNotifyName;
}
package com.ebaiyihui.alarm.server.service.Impl;
import com.ebaiyihui.alarm.server.config.ProjProperties;
import com.ebaiyihui.alarm.server.config.ServiceInfo;
import com.ebaiyihui.alarm.server.entity.AlarmMessage;
import com.ebaiyihui.alarm.server.service.AlarmService;
import com.ebaiyihui.alarm.server.util.HttpKit;
......@@ -42,10 +43,12 @@ public class AlarmServiceImpl implements AlarmService {
String message = alarmMessage.getAlarmMessage();
// 获取服务名称
String serviceNme = name.substring(name.indexOf("byh"), name.length());
// 云端通知人员
if (projProperties.getCloudBaseService().contains(serviceNme)) {
List<ServiceInfo> serviceInfos = projProperties.getServiceInfo();
for (ServiceInfo serviceInfo : serviceInfos) {
// 相应的服务通知对应人员
if (serviceInfo.getServiceNames().contains(serviceNme)) {
// message += "<at user_id=\\\"ou_6cb2f35f9bf8e7d7e977483801ab13de\\\">杨凯</at>";
message += "<at user_id=\\\"" + projProperties.getCloudBaseNotifyName() + "\\\"></at>";
message += "<at user_id=\\\"" + serviceInfo.getServiceNotifyName() + "\\\"></at>";
alarmMessage.setAlarmMessage(message);
}
String sendMessage = "{\"msg_type\":\"text\",\"content\":{\"text\":\"Apache SkyWalking Alarm: \\n %s.\"}}";
......@@ -56,6 +59,8 @@ public class AlarmServiceImpl implements AlarmService {
return "fail";
}
}
}
return "success";
}
......
......@@ -81,5 +81,6 @@ secret: OV5mmyDxX5Nx0caMYQp3Kg
# ou_534ec59ce6a625046da2b51896ec2764 赵凯
projprops:
cloud_base_service: byh-doctor-service-basedata01_cloud-pro,byh-doctor-service-basedata02_cloud-pro,byh-doctoruser-service-core01_cloud-pro,byh-doctoruser-service-core02_cloud-pro,byh-sysinfocloud-service_cloud-pro,byh-ehospital-im01_cloud-pro,byh-ehospital-im02_cloud-pro
cloud_base_notify_name: ou_6cb2f35f9bf8e7d7e977483801ab13de
\ No newline at end of file
serviceInfo[0]:
service_names: byh-doctor-service-basedata01_cloud-pro,byh-doctor-service-basedata02_cloud-pro,byh-doctoruser-service-core01_cloud-pro,byh-doctoruser-service-core02_cloud-pro,byh-sysinfocloud-service_cloud-pro,byh-ehospital-im01_cloud-pro,byh-ehospital-im02_cloud-pro
service_notify_name: ou_6cb2f35f9bf8e7d7e977483801ab13de
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论