处理审计日志相关字段与运控系统日志映射

develop
bayuzhen 2024-08-29 14:26:49 +08:00
parent 78ea3f525d
commit d23ec80f67
1 changed files with 81 additions and 4 deletions

View File

@ -51,12 +51,12 @@ public class LogServiceImpl implements LogService {
@Autowired @Autowired
private KafkaTemplate<String, LogModel> kafkaTemplate; private KafkaTemplate<String, LogModel> kafkaTemplate;
@Value("${log.push.systemNumber:0}")
private String systemNumber; // 日志推送系统编号
@Value("${log.push.systemNameCn:0}")
private String systemNameCn; // 日志推送系统名称
@Value("${log.push.topic:YK_USER_LOG_TOPIC}") @Value("${log.push.topic:YK_USER_LOG_TOPIC}")
private String topic; // 日志推送主题名称 private String topic; // 日志推送主题名称
@Value("${log.push.systemNumber:0101070000010005}")
private String systemNumber; // 日志推送系统编号
@Value("${log.push.systemNameCn:云管平台}")
private String systemNameCn; // 日志推送系统名称
@Value("${log.push.enable:false}") @Value("${log.push.enable:false}")
private Boolean enable; // 日志推送开关 private Boolean enable; // 日志推送开关
@Value("${spring.cloud.zookeeper.discovery.instance-host:127.0.0.1}") @Value("${spring.cloud.zookeeper.discovery.instance-host:127.0.0.1}")
@ -214,10 +214,16 @@ public class LogServiceImpl implements LogService {
if (userMap.containsKey(accessLog.getUserId())) { if (userMap.containsKey(accessLog.getUserId())) {
kafkaLog.setSubjectName(userMap.get(accessLog.getUserId())); kafkaLog.setSubjectName(userMap.get(accessLog.getUserId()));
} }
String logType = convertLogType(accessLog);
kafkaLog.setLogType(logType);
kafkaLog.setSystemNumber(systemNumber); kafkaLog.setSystemNumber(systemNumber);
kafkaLog.setSystemNameCn(systemNameCn); kafkaLog.setSystemNameCn(systemNameCn);
kafkaLog.setSystemAddress(host); kafkaLog.setSystemAddress(host);
kafkaLog.setMessage(accessLog.getAction()); kafkaLog.setMessage(accessLog.getAction());
String objectType = convertObjectType(accessLog);
kafkaLog.setObjectType(objectType);
String operation = convertOperation(accessLog);
kafkaLog.setOperation(operation);
kafkaLog.setSubjectAddress(accessLog.getRequestIp()); kafkaLog.setSubjectAddress(accessLog.getRequestIp());
kafkaLog.setStartTime(simpleFormat.format(accessLog.getGmtCreate())); kafkaLog.setStartTime(simpleFormat.format(accessLog.getGmtCreate()));
String outcome = "0"; String outcome = "0";
@ -234,4 +240,75 @@ public class LogServiceImpl implements LogService {
} }
private String convertOperation(AccessLog accessLog) {
// 参考系统操作日志标准V20240528 文档
switch (accessLog.getAction()) {
case "主页配置列表展示":
return "101";
case "订单数量统计":
case "获取平台信息":
case "获取服务列表":
case "获取网段列表":
case "根据code查询服务类型":
case "作业模板列表":
case "同步云供应商数据":
case "获取主机资源列表":
case "作业实例列表":
return "105";
case "恢复快照":
return "109";
case "资源池分组":
case "云主机用户分配":
case "更新系统配置":
return "403";
case "订单分析概览":
return "410";
default:
return "5";
}
}
private String convertObjectType(AccessLog accessLog) {
// 参考系统操作日志标准V20240528 文档
switch (accessLog.getTarget()) {
case "系统配置管理":
case "运营分析管理":
case "首页概览数据":
return "1";
case "云服务管理":
return "2";
case "云供应商":
case "主机资源":
return "4";
case "作业实例管理":
case "流程实例":
case "作业模板管理":
case "作业场景管理":
return "10";
case "云主机管理":
return "12";
case "权限管理":
return "14";
default:
return "5";
}
}
private String convertLogType(AccessLog accessLog) {
// 登录, 登出
if (accessLog.getTarget().equals("登录管理") && accessLog.getAction().equals("用户登录系统")) {
return "2";
}
if (accessLog.getTarget().equals("登录管理") && accessLog.getAction().equals("用户退出系统")) {
return "3";
}
if (accessLog.getCatalog().equals("Manager")) {
return "1";
}
if (accessLog.getCatalog().equals("User")) {
return "4";
}
return "5";
}
} }